Deploy static content to Cloudflare Pages #667
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy static content to Cloudflare Pages | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # 每天UTC 0点 (北京时间8点) | |
| - cron: '0 10 * * *' # 每天UTC 10点 (北京时间18点) | |
| # Runs on pushes targeting the default branch | |
| push: | |
| branches: [main, prod] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| deployments: write | |
| name: Publish to Cloudflare Pages | |
| steps: | |
| - name: Debug info | |
| run: | | |
| echo "🚀 Workflow triggered by: ${{ github.event_name }}" | |
| echo "⏰ UTC Time: $(date -u)" | |
| echo "🇨🇳 Beijing Time: $(TZ='Asia/Shanghai' date)" | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: update sponsor list | |
| run: python scripts/sponsor.py | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24.x' | |
| cache: 'npm' | |
| cache-dependency-path: '**/package-lock.json' | |
| - run: npm ci | |
| - name: Replace URL | |
| # if you put those in secrets, you can replace vars by secrets | |
| run: | | |
| sed -i "s#https://urlplaceholder.com#${{ vars.CF_PAGES_URL }}#g" ./docusaurus.config.js | |
| sed -i "s#/baseurlplaceholder#${{ vars.CF_PAGES_BASEURL }}#g" ./docusaurus.config.js | |
| - name: Build website | |
| run: | | |
| rm -f AGENTS.md | |
| npm run build | |
| - name: Publish to Cloudflare Pages | |
| uses: cloudflare/pages-action@v1 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| # change projectName to your project name | |
| projectName: ${{ vars.CF_PROJRCT_NAME }} | |
| directory: ./ | |
| # Optional: Enable this if you want to have GitHub Deployments triggered | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
| # Optional: Switch what branch you are publishing to. | |
| # By default this will be the branch which triggered this workflow | |
| branch: ${{ github.ref_name }} | |
| # Optional: Change the working directory | |
| # All my website content is in the site folder | |
| workingDirectory: ./build/ | |
| # Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` | |
| wranglerVersion: '3' | |