Skip to content

Merge branch 'main' into feat/rps-204-safety-state-handling #186

Merge branch 'main' into feat/rps-204-safety-state-handling

Merge branch 'main' into feat/rps-204-safety-state-handling #186

Workflow file for this run

# https://github.com/orgs/community/discussions/21582
name: Build and Publish Storybook to GitHub Pages
on:
# Event for the workflow to run on
push:
branches:
- '**' # Run on all branches
permissions:
contents: write
pages: write
id-token: write
actions: read
concurrency:
group: "pages"
cancel-in-progress: true
# List of jobs
jobs:
build_matrix:
runs-on: ubuntu-latest
outputs:
json_branches: ${{ steps.generate-matrix.outputs.json_branches }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate Matrix
id: generate-matrix
run: |
branches=($(git branch -r | cut -c 3- | sed 's/origin\///g'))
json_branches=$(printf '%s\n' "${branches[@]}" | jq -R . | jq -s -c .)
echo "json_branches=${json_branches}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
name: Build
env:
HUSKY: 0
needs:
- build_matrix
strategy:
matrix:
branch: ${{ fromJSON(needs.build_matrix.outputs.json_branches) }}
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm ci
- name: Build Storybook
run: npm run build-storybook
- name: Sanitize branch name
id: sanitize
run: echo "SANITIZED_BRANCH=$(echo ${{ matrix.branch }} | sed 's/\//-/g')" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: ${{ env.SANITIZED_BRANCH }}
path: storybook-static/
deploy:
runs-on: ubuntu-latest
name: Deploy
env:
HUSKY: 0
if: always()
needs:
- build_matrix
- build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Clean public folder
run: rm -rf public/*
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.SANITIZED_BRANCH }}
path: public/
- name: Generate overview.html
run: |
echo "<html><body><h1>Storybook Versions</h1><ul>" > public/overview.html
for dir in $(ls public); do
echo "<li><a href=\"$dir\">$dir</a></li>" >> public/overview.html
done
echo "</ul></body></html>" >> public/overview.html
- name: Move content from /public/main to public
run: |
rsync -a public/main/ public/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4