-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (126 loc) · 5.17 KB
/
cloudflare-pages.yml
File metadata and controls
128 lines (126 loc) · 5.17 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
name: cloudflare-pages
# Trigger the workflow when:
on:
# A push occurs to one of the matched branches.
push:
branches: [master]
# Or when a pull request event occurs for a pull request against one of the
# matched branches.
pull_request:
branches: [master]
jobs:
cloudflare-pages:
# This name appears in GitHub's Checks API.
name: cloudflare-pages
# Do not trigger job for dependency update bot.
if: github.actor != 'renovate[bot]'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
# In progress comment will be updated with a deploy status.
- name: Add in progress comment to PR
# We want to add in progress comment on a pull request event only.
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v2
with:
message: |
## Deploying with <a href="https://pages.dev">Cloudflare Pages</a>
<table>
<tr>
<td><strong>Latest commit:</strong></td>
<td><code>${{ github.event.pull_request.head.sha }}</code></td>
</tr>
<tr>
<td><strong>Status:</strong></td><td>⏳ In progress</td>
</tr>
</table>
- name: Checkout code
uses: actions/checkout@v4
# Checkout pull request HEAD commit instead of merge commit.
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: 'recursive'
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: '20.x'
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10
run_install: false
- name: Set workflow variables
# Id is needed to access output in a next step.
id: vars
run: |
echo "PNPM_CACHE_DIR=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.vars.outputs.PNPM_CACHE_DIR }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build subcall lib
run: pnpm --filter @oasisprotocol/rose-app-subcall build
- name: Build app
run: pnpm build
- name: Publish to Cloudflare Pages
# Id is needed to access output in a next step.
id: deploy
uses: cloudflare/wrangler-action@v3
with:
# Token with Cloudflare Pages edit permission only generated in Cloudflare dashboard -> Manage Account -> Account API Tokens
apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }}
# Acquired from Cloudflare dashboard -> Compute > Workers & Pages or dashboard url: https://dash.cloudflare.com/<account-id>/
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# Project created via Cloudflare dashboard or CLI command "npx wrangler pages project create <project-name>"
command: pages deploy ./home/dist --project-name=rose-app --branch ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || '' }}
# On a subsequent run the original comment will be updated.
- name: Update PR comment
uses: mshick/add-pr-comment@v2
# We want to update a comment on a pull request event only.
if: github.event_name == 'pull_request' && always()
with:
message: |
## Deployed to <a href="https://pages.dev">Cloudflare Pages</a>
<table>
<tr>
<td><strong>Latest commit:</strong></td>
<td><code>${{ github.event.pull_request.head.sha }}</code></td>
</tr>
<tr>
<td><strong>Status:</strong></td><td>✅ Deploy successful!</td>
</tr>
<tr>
<td><strong>Preview URL:</strong></td>
<td><a href="${{ steps.deploy.outputs.deployment-url }}">${{ steps.deploy.outputs.deployment-url }}</a></td>
</tr>
<tr>
<td><strong>Alias:</strong></td>
<td><a href="${{ steps.deploy.outputs.pages-deployment-alias-url }}">${{ steps.deploy.outputs.pages-deployment-alias-url }}</a></td>
</tr>
</table>
message-failure: |
## Deployed to <a href="https://pages.dev">Cloudflare Pages</a>
<table>
<tr>
<td><strong>Latest commit:</strong></td>
<td><code>${{ github.event.pull_request.head.sha }}</code></td>
</tr>
<tr>
<td><strong>Status:</strong></td><td>🚫 Deploy failed!</td>
</tr>
</table>
message-cancelled: |
## Deployed to <a href="https://pages.dev">Cloudflare Pages</a>
<table>
<tr>
<td><strong>Status:</strong></td><td>✖️ Deploy cancelled!</td>
</tr>
</table>