Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
use github cache instead of api.github.com
Browse files Browse the repository at this point in the history
  • Loading branch information
IceCodeNew committed Feb 23, 2023
1 parent abeadf2 commit c8571b3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,32 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set some variables
run: |
set -x
GITHUB_API_BASEURL='https://api.github.com'
TMP_FILE=$(mktemp)
if curl -sS -i -I -H "Accept: application/vnd.github.v3+json" -o "$TMP_FILE" -- 'https://github-cache.yingmale.win/api/'; then
HTTP_STATUS_CODE=$(awk 'NR==1 {print $2}' "$TMP_FILE")
if [[ $HTTP_STATUS_CODE -ge 200 ]] && [[ $HTTP_STATUS_CODE -le 299 ]]; then
GITHUB_API_BASEURL='https://github-cache.yingmale.win/api'
echo "info: github cache is ready, will use ${GITHUB_API_BASEURL} as GITHUB_API_BASEURL."
fi
fi
"rm" -f "$TMP_FILE"
echo "GITHUB_API_BASEURL=${GITHUB_API_BASEURL}" >> $GITHUB_ENV
echo "RELEASE_NAME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "REPO_URL=github.com/${{ github.repository }}" >> $GITHUB_ENV
echo "jemalloc_latest_tag_name=$(curl -sL -H 'Accept: application/vnd.github.v3+json' \
'https://api.github.com/repos/jemalloc/jemalloc/releases/latest' |
"${GITHUB_API_BASEURL}/repos/jemalloc/jemalloc/releases/latest" |
grep -F 'tag_name' | cut -d'"' -f4)" >> $GITHUB_ENV
echo "jemalloc_latest_commit_hash=$(curl -sSL --fail --retry 5 --retry-delay 10 --retry-max-time 60 -H 'Accept: application/vnd.github.v3+json' \
'https://api.github.com/repos/jemalloc/jemalloc/commits?per_page=1' |
"${GITHUB_API_BASEURL}/repos/jemalloc/jemalloc/commits?per_page=1" |
grep -Fm1 'sha' | cut -d'"' -f4)" >> $GITHUB_ENV
echo "lua_version=$(curl -sSL \
"https://www.lua.org/download.html" | tr -d '\r\n\t' |
Expand All @@ -51,6 +64,7 @@ jobs:
grep -Po "(?<=a=shortlog;h=refs\/tags\/v)${haproxy_branch}\.[0-9]+" |
LC_ALL=C sort -Vr | head -n 1)" >> $GITHUB_ENV
echo "image_build_date=$(TZ=':Asia/Taipei' date +%F)" >> $GITHUB_ENV
set +x
shell: bash
# Runs a set of commands using the runners shell
- name: Force push `release` branch
Expand Down

0 comments on commit c8571b3

Please sign in to comment.