Repository navigation
56 lines (55 loc) · 2.42 KB
/
Copy pathcf-deploy.yaml
File metadata and controls
56 lines (55 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: CloudFlare Deploy
on:
push:
branches-ignore:
- 'gh-readonly-queue/**'
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '22'
package-manager-cache: false
- run: corepack enable
- run: yarn --immutable
- run: yarn build
- name: Publish to Cloudflare Pages
id: deploy
uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ./out --project-name=forest-website --branch=${{ github.ref_name }}
- name: Record GitHub deployment
uses: actions/github-script@v9
env:
PAGES_ENVIRONMENT: ${{ steps.deploy.outputs.pages-environment }}
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
with:
# Some vibe-coded workaround due to us sitting on direct upload which we can't migrate without creating a new project.
# To be done in the future. See <https://developers.cloudflare.com/pages/get-started/direct-upload/>
script: |
const production = process.env.PAGES_ENVIRONMENT
? process.env.PAGES_ENVIRONMENT === 'production'
: context.ref === 'refs/heads/main'
const { data: deployment } = await github.rest.repos.createDeployment({
...context.repo,
ref: context.sha,
environment: production ? 'forest-website (Production)' : 'forest-website (Preview)',
auto_merge: false,
required_contexts: [],
production_environment: production,
transient_environment: !production,
})
await github.rest.repos.createDeploymentStatus({
...context.repo,
deployment_id: deployment.id,
state: 'success',
environment_url: process.env.DEPLOYMENT_URL,
log_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
})