-
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (77 loc) · 2.02 KB
/
deploy.yml
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Deploy
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: cache
id: cache-frontend
uses: actions/cache@v3
with:
key: frontend-$NODE_ENV-${{ hashFiles('**/package-lock.json') }}
path: |
node_modules
restore-keys: |
frontend-$NODE_ENV-
frontend-
- run: npm install
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
needs: build
name: Deploy
env:
NODE_ENV: production
outputs:
preview_url: ${{ steps.cloudflare-deploy.outputs.url }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- uses: actions/cache@v3
with:
key: frontend-$NODE_ENV-${{ hashFiles('**/package-lock.json') }}
path: |
node_modules
restore-keys: |
frontend-$NODE_ENV-
frontend-
- run: npm run build
- name: Deploy
id: cloudflare-deploy
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: erison-work # e.g. 'my-project'
directory: dist # e.g. 'dist'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
comment:
runs-on: ubuntu-latest
needs:
- deploy
name: Add comment in Pull request
steps:
- name: Comment PR
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PREVIEW_URL: ${{ steps.cloudflare-deploy.outputs.url }}
with:
message: |
🚀 This branch can be previewed at ${{ needs.deploy.outputs.preview_url }}