Skip to content

ci: add GitHub Actions workflow to build and deploy _worker.js #3

ci: add GitHub Actions workflow to build and deploy _worker.js

ci: add GitHub Actions workflow to build and deploy _worker.js #3

Workflow file for this run

name: Build
on:
push:
branches:
- main
- deploy
paths-ignore:
- 'README.md'
- '.gitignore'
workflow_dispatch: # 允许手动触发
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # 允许推送到仓库
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build _worker.js
run: npm run build
# 等待 60 秒,避免连续两次提交导致 Cloudflare Pages 跳过部署
- name: Wait for Cloudflare to process previous commit
run: sleep 60
- name: Commit and push _worker.js
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -f _worker.js
git diff --staged --quiet || git commit -m "chore: auto-build _worker.js [skip ci]"
git push origin HEAD:${{ github.ref_name }}