Skip to content

Commit

Permalink
Use a var for cloudflare preview project name
Browse files Browse the repository at this point in the history
I'm setting up a new CloudFlare account and a new token and trying
to get the pre-merge preview working with wrangler.

I set the var at the org level to "conforma" in the new org and
"enterprise-contract" in the existing org.

What I did to set up the Cloudflare account and token:
* Sign up via https://pages.cloudflare.com/
* Create a token. Use the permissions preset as suggested
  at cloudflare/wrangler-action#233
* Create a GitHub org secret for it called CLOUDFLARE_API_TOKEN
  at the org level, (but limited it to just this repo).
* Create a "pages" project in Cloudflare by clicking "+ Add", then
  "Pages". Name it "conforma", then set a org var called
  CLOUDFLARE_PROJECT_NAME, also limited to just this repo.
  • Loading branch information
simonbaird committed Jan 21, 2025
1 parent 9e92c14 commit a37ba33
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ jobs:
id: preview
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_PROJECT_NAME: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
run: |
npm --prefix code ci
npm --prefix code exec -- wrangler pages deploy public --project-name enterprise-contract --branch pr-${{ steps.data.outputs.PR_NUMBER }} | tee out.txt
npm --prefix code exec -- wrangler pages deploy public --project-name "$CLOUDFLARE_PROJECT_NAME" --branch pr-${{ steps.data.outputs.PR_NUMBER }} | tee out.txt
grep 'Deployment complete! Take a peek over at ' out.txt | sed -e 's/.*over at /PREVIEW_URL=/' >> $GITHUB_OUTPUT
- name: Add comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand Down

0 comments on commit a37ba33

Please sign in to comment.