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