Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/deploy-cloudflare-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Workflow name
name: Build and Publish Storybook to CloudFlare Pages

on:
# workflow will run on any push
push: {}

permissions:
contents: read

jobs:

deploy:
runs-on: ubuntu-latest

# Job steps
steps:
# Manual Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Set up Node
- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Build Storybook
run: npx storybook build --output-dir storybook-static

# Determines to publish on dev or main
- name: Set Cloudflare Pages branch
id: cf
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
echo "branch=main" >> "$GITHUB_OUTPUT"
else
echo "branch=development" >> "$GITHUB_OUTPUT"
fi

# Publishes to dev if no tag on commit, otherwise publishes to main(production)
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: storybook-fields
directory: storybook-static
branch: ${{ steps.cf.outputs.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}