Skip to content

Commit 6b173dc

Browse files
committed
Add workflow script to deploy to CloudFlare Pages
1 parent 64a53fc commit 6b173dc

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Workflow name
2+
name: Build and Publish Storybook to CloudFlare Pages
3+
4+
on:
5+
# workflow will run on any push
6+
push: {}
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
13+
deploy:
14+
runs-on: ubuntu-latest
15+
16+
# Job steps
17+
steps:
18+
# Manual Checkout
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
# Set up Node
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Build Storybook
31+
run: npx storybook build --output-dir storybook-static
32+
33+
# Determines to publish on dev or main
34+
- name: Set Cloudflare Pages branch
35+
id: cf
36+
run: |
37+
if [ "${{ github.ref_type }}" = "tag" ]; then
38+
echo "branch=main" >> "$GITHUB_OUTPUT"
39+
else
40+
echo "branch=development" >> "$GITHUB_OUTPUT"
41+
fi
42+
43+
# Publishes to dev if no tag on commit, otherwise publishes to main(production)
44+
- name: Publish to Cloudflare Pages
45+
uses: cloudflare/pages-action@v1
46+
with:
47+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
48+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
49+
projectName: storybook-tangible-fields
50+
directory: storybook-static
51+
branch: ${{ steps.cf.outputs.branch }}
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)