-
Notifications
You must be signed in to change notification settings - Fork 16
50 lines (45 loc) · 1.75 KB
/
cloudflare-pages.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
name: Cloudflare Pages
on: [push]
jobs:
publish:
runs-on: ubuntu-20.04
permissions:
contents: read
deployments: write
statuses: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4.1.0
with:
node-version: 20.x
# base: https://github.com/actions/setup-node/issues/214#issuecomment-810829250
- name: Reconfigure git to use HTTPS authentication for npm-dependencies using Git
run: git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- run: npm ci
- run: SITE_URL="https://piping-ui.org" npm run build
- name: Publish to Cloudflare Pages
id: cloudflare_pages_deploy
uses: cloudflare/pages-action@1
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
projectName: piping-ui
directory: ./dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Add publish URL as commit status
uses: actions/github-script@v7
with:
script: |
// When "pull_request", context.payload.pull_request?.head.sha is expected SHA.
// (base: https://github.community/t/github-sha-isnt-the-value-expected/17903/2)
const sha = context.payload.pull_request?.head.sha ?? context.sha;
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
context: 'Cloudflare Pages',
description: 'Cloudflare Pages deployment',
state: 'success',
sha,
target_url: "${{ steps.cloudflare_pages_deploy.outputs.url }}",
});