Marcus
01/05/2024, 5:06 PMcloudflare/pages-action
? I'm trying to simulate the nice chatops-y build status message the cloudflare build process creates when building in Github instead for more control.Marcus
01/05/2024, 5:08 PMyaml
- name: Deploy preview to Cloudflare
uses: cloudflare/pages-action@1
id: pages-action
with:
apiToken: ${{ secrets.CI_CF_PAGES }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: ${{ env.PAGES_PROJECT_NAME }}
directory: dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
id: ${{ steps.pages-action.outputs.id }}
url: ${{ steps.pages-action.outputs.url }}
alias: ${{ steps.pages-action.outputs.alias }}
environment: ${{ steps.pages-action.outputs.environment }}
comment_tag: deployment
mode: upsert
Marcus
01/05/2024, 5:13 PMalias
is just the URLMarcus
01/05/2024, 6:33 PMcloudflare/pages-action
that prevent this from working, as noted in the issues for the repo: a) one needs to manually set the deployment branch to ${{ github.head_ref || github.ref_name }}
even though the documentation suggests you don't, and b) even if you do, outputs.alias
doesn't work. The wrangler action is way more updated (supports pnpm, for one), and you can use command: pages deploy
with it, but it doesn't output the branch URL (or make a github deployment?) either.
For now I just faked the whole thing:
yaml
- name: Deploy preview to Cloudflare
uses: cloudflare/pages-action@1
id: pages-action
with:
apiToken: ${{ secrets.CI_CF_PAGES }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: ${{ env.PAGES_PROJECT_NAME }}
directory: dist
branch: ${{ github.head_ref || github.ref_name }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Deployed ${{ steps.pages-action.outputs.environment }} build to Cloudflare!
| | |
| ----------------------- | - |
| **Last commit:** | ${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha || github.sha }} |
| **Preview URL**: | ${{ steps.pages-action.outputs.url }} |
| **Branch Preview URL**: | https://${{ github.head_ref || github.ref_name }}.${{ env.PAGES_PROJECT_NAME }}.pages.dev |
comment_tag: deployment
mode: upsert