Github integration after deploying with Wrangler

I deployed directly with wrangler, and would now like to deploy preview branches automatically. Cloudflare already has access to my gh account (I have the app). If I push the repo up it's not clear to me how cloudflare will identify and deploy it. I don't see a way to configure this in the CF dashboard.
1 Reply
stukennedy
stukennedy13mo ago
I'm having the same issue ... trying a few approaches. Just posted my own question on this. I'm also struggling with the Github branches thing even if you setup a new project. I've switched to using Github Actions, and they work really well. you just need to create a file .github/workflows/pages-deployment.yaml with this sort of content
on: [push]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: npm install && npm run build
- name: Run Tests
run: npm test
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: 'YOUR_PROJECTNAME'
directory: 'YOUR_STATIC_FILES_DIRECTORY'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
on: [push]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: npm install && npm run build
- name: Run Tests
run: npm test
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: 'YOUR_PROJECTNAME'
directory: 'YOUR_STATIC_FILES_DIRECTORY'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
You'll need to get CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID from the Cloudflare Dashboard and add them to the Github secrets, it already has access to GITHUB_TOKEN Been working great for me, deploys any master merges to production and any other branches to preview.
Want results from more Discord servers?
Add your server