-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (50 loc) · 1.89 KB
/
publish-cf-pages.yaml
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
on:
# push: # not required?
# branches:
# - main
pull_request: {} # NOTE: worktree would be a temporal merge commit
workflow_dispatch: {}
# inputs:
# environment:
# description: "Choose an environment to deploy to: <Preview|Production>"
# required: true
# default: "Preview"
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "20"
cache: npm
cache-dependency-path: 'package-lock.json'
- run: npm ci
- uses: actions/cache@v4
with:
path: web/.next
key: ${{ runner.os }}-next-build-${{ hashFiles('package-lock.json') }}
- run: npm run --workspace=web build:pages
- id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
wranglerVersion: '3.36.0' # same as in /package.json
command: |
pages deploy web/.vercel/output/static --project-name=slides-ihate-work-monorepo --branch=${{ github.ref_name }} --commit-hash=${{ github.sha }} --env=${{ (github.ref_name == 'main' && 'Production') || (github.ref_name != 'main' && 'Preview') }}
- name: print deployment-url
env:
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
run: echo $DEPLOYMENT_URL
- uses: thollander/actions-comment-pull-request@v2
with:
message: |
Deployed to CF pages (Preview) at ${{ steps.deploy.outputs.deployment-url }}
comment_tag: deploy_preview
if: ${{ github.ref_name != 'main' }}
- uses: thollander/actions-comment-pull-request@v2
with:
message: |
Deployed to CF pages (Prod) at ${{ steps.deploy.outputs.deployment-url }}
comment_tag: deploy_prod
if: ${{ github.ref_name == 'main' }}