Update deploy.yml #24
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 to Cloudflare Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| deployments: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive # Fetch Hugo themes (if any) | |
| fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "lts/*" | |
| - name: Check for typos | |
| uses: crate-ci/typos@v1 | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| hugo-version: 'latest' | |
| extended: true | |
| - name: Build Hugo site | |
| env: | |
| HUGO_ENV_GIT_COMMIT_HASH: ${{ github.sha }} | |
| run: hugo --minify --gc --cleanDestinationDir --environment production | |
| - name: Check deployment conditions | |
| id: check-deploy | |
| run: | | |
| if [ -n "${{ secrets.CLOUDFLARE_API_TOKEN }}" ]; then | |
| echo "should_deploy=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_deploy=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Deploy to Cloudflare Pages | |
| if: steps.check-deploy.outputs.should_deploy == 'true' && github.event_name != 'pull_request' | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
| command: | | |
| pages deploy public --project-name=${{ secrets.CLOUDFLARE_PROJECT_NAME }} --branch=${{ github.head_ref || github.ref_name }} --commit-dirty=true |