Skip to content

Commit 4472ba1

Browse files
committed
build: add new action to deploy docs
1 parent a774dae commit 4472ba1

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy Website to Cloudflare Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- main
8+
paths:
9+
- 'website/**'
10+
workflow_dispatch:
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
deployments: write
18+
name: Deploy to Cloudflare Pages
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22.x'
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v2
30+
with:
31+
version: 8
32+
33+
- name: Install dependencies
34+
run: pnpm recursive install
35+
36+
- name: Build website
37+
run: pnpm run build:docs
38+
39+
- name: Determine Cloudflare target
40+
id: cf-branch
41+
run: |
42+
if [ "${GITHUB_REF_NAME}" = "develop" ]; then
43+
echo "branch=preview" >> "$GITHUB_OUTPUT"
44+
echo "domain=preview.idpass-data-collect.pages.dev" >> "$GITHUB_OUTPUT"
45+
elif [ "${GITHUB_REF_NAME}" = "main" ]; then
46+
echo "branch=main" >> "$GITHUB_OUTPUT"
47+
echo "domain=idpass-data-collect.pages.dev" >> "$GITHUB_OUTPUT"
48+
else
49+
echo "Unsupported branch ${GITHUB_REF_NAME}" >&2
50+
exit 1
51+
fi
52+
53+
- name: Announce deployment target
54+
run: |
55+
echo "Deploying branch ${GITHUB_REF_NAME} to ${{ steps.cf-branch.outputs.domain }}"
56+
57+
- name: Deploy to Cloudflare Pages
58+
uses: cloudflare/wrangler-action@v3
59+
with:
60+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
61+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
62+
command: pages deploy website/build --project-name=data-collect --branch=${{ steps.cf-branch.outputs.branch }}

0 commit comments

Comments
 (0)