CI: multiple changes

- Reuse build dir var
- Use treeless clone for downloading previous build dist
- Update cloudflare wrangler version
- Use amd64 CI for deployments
- Tune CI Networks
This commit is contained in:
SukkaW 2025-07-31 21:39:35 +08:00
parent 97b9f16bc6
commit c26a194e45

View File

@ -17,9 +17,8 @@ jobs:
runs-on: ubuntu-24.04-arm
steps:
# - name: Tune GitHub-hosted runner network
# # https://github.com/actions/runner-images/issues/1187
# uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: smorimoto/tune-github-hosted-runner-network@v1
# https://github.com/actions/runner-images/issues/1187
- uses: actions/checkout@v4
with:
persist-credentials: false
@ -30,17 +29,19 @@ jobs:
with:
node-version-file: ".node-version"
cache: "pnpm"
- name: Grab Building Folder
id: ramdisk
run: |
echo "build_dir=previous-build-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_OUTPUT
- name: Download Previous Build
uses: actions/checkout@v4
with:
repository: SukkaLab/ruleset.skk.moe
persist-credentials: false
path: previous-build-${{ github.run_id }}-${{ github.run_number }}
filter: "tree:0" # we don't care about git history here
fetch-tags: false
path: ${{ steps.ramdisk.outputs.build_dir }}
token: ${{ secrets.GIT_TOKEN }}
- name: Grab Building Folder
id: ramdisk
run: |
echo "build_dir=previous-build-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_OUTPUT
- name: Setup build folder
run: |
if [ ! -d ${{ steps.ramdisk.outputs.build_dir }}/.git ]; then
@ -115,6 +116,7 @@ jobs:
path: |
.cache
key: ${{ runner.os }}-v3-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }} ${{ steps.date.outputs.hour }}:${{ steps.date.outputs.minute }}:${{ steps.date.outputs.second }}
diff_deployment_on_pr:
if: github.ref != 'refs/heads/master'
needs:
@ -140,45 +142,41 @@ jobs:
- build
name: Deploy to Cloudflare Pages
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-24.04-arm
runs-on: ubuntu-24.04
# matrix is a tricky way to define a variable directly in the action yaml
strategy:
matrix:
wranglerVersion: ['3.114.9']
wranglerVersion: ['3.114.12']
steps:
- name: Get NPM cache directory path
id: npm_cache_path
shell: sh
run: echo dir=$(npm config get cache) >> $GITHUB_OUTPUT
- uses: actions/cache/restore@v4
- uses: actions/cache@v4
with:
path: |
${{ steps.npm_cache_path.outputs.dir }}
node_modules
key: deploy-to-cloudflare-npm-${{ runner.os }}-${{ runner.arch }}-wrangler-${{ matrix.wranglerVersion }}
restore-keys: |
deploy-to-cloudflare-npm-${{ runner.os }}-${{ runner.arch }}-wrangler-
- uses: actions/download-artifact@v4
with:
name: build-artifact-${{ github.sha }}-${{ github.run_number }}
path: public
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy public --project-name=sukkaw-ruleset --commit-dirty=true --branch=main
wranglerVersion: ${{ matrix.wranglerVersion }}
- uses: actions/cache/save@v4
with:
path: |
${{ steps.npm_cache_path.outputs.dir }}
node_modules
key: deploy-to-cloudflare-npm-${{ runner.os }}-${{ runner.arch }}-wrangler-${{ matrix.wranglerVersion }}
deploy_to_github_gitlab:
needs:
- build
name: Deploy to GitHub and GitLab
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-24.04-arm
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@v4
with: