diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d04c471b..af98976a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -43,22 +43,25 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy docs/target/site/ --project-name=lz4-java-yawk-at --branch=main - - name: Publish preview + # Dispatch on main is a production rebuild; any other branch gives a preview deployment. + # wrangler-action runs the command without a shell, so the ref can't be passed via env var. + - name: Publish (manual dispatch) if: github.event_name != 'release' uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4 - id: cf_publish_preview + id: cf_publish_dispatch with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy docs/target/site/ --project-name=lz4-java-yawk-at + command: pages deploy docs/target/site/ --project-name=lz4-java-yawk-at --branch=${{ github.ref_name }} + # Not on main: that deploy is production, and the only associated PR is an already-merged one. - name: Check PR - if: github.event_name != 'release' + if: github.event_name != 'release' && github.ref != 'refs/heads/main' uses: 8BitJonny/gh-get-current-pr@4056877062a1f3b624d5d4c2bedefa9cf51435c9 # 4.0.0 id: pr - name: Comment on PR if: steps.pr.outputs.pr_found uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3 with: - message: ":rocket: Preview deployed to ${{steps.cf_publish_preview.outputs.deployment-url}}" + message: ":rocket: Preview deployed to ${{steps.cf_publish_dispatch.outputs.deployment-url}}" comment-tag: deployment pr-number: "${{steps.pr.outputs.number}}"