-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (72 loc) · 2.78 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
87
88
89
90
name: Deploy to Cloudflare Pages
on:
workflow_run:
workflows: ['CI']
types: ['completed']
workflow_dispatch:
concurrency:
group: 'pages'
cancel-in-progress: true
permissions:
pull-requests: write
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
jobs:
deploy-on-ci-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Comment start deploying preview
if: ${{ github.event.workflow_run.event != 'push' }}
uses: mshick/add-pr-comment@v2
with:
issue: ${{ github.event.workflow_run.pull_requests[0].number }}
message-id: cloudflare-pages-preview-deployment
message: |
## <span aria-hidden="true">📤</span> Start Deploying preview...
| Name | Link |
| ---- | ---- |
| **Latest commit** | ${{ github.event.workflow_run.head_sha }} |
| **Latest deploy log** | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.7.5
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm build
- name: Deploy
uses: cloudflare/pages-action@v1
id: deploy-cloudflare-pages
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: portfolio
directory: ./apps/portfolio/dist/
- name: Comment preview deployed successful
if: ${{ github.event.workflow_run.event != 'push' }}
uses: mshick/add-pr-comment@v2
with:
issue: ${{ github.event.workflow_run.pull_requests[0].number }}
message-id: cloudflare-pages-preview-deployment
message: |
## <span aria-hidden="true">✅</span> Preview Deployed Successfully!
| Name | Link |
| ---- | ---- |
| **Latest commit** | ${{ github.event.workflow_run.head_sha }} |
| **Latest deploy log** | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| **Preview URL (Latest)** | ${{ steps.deploy-cloudflare-pages.outputs.url }} |
| **Preview URL (Branch)** | ${{ steps.deploy-cloudflare-pages.outputs.alias }} |