diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 278a0b90..2c390c3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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' | @@ -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