fix: move content from main folder to public #147
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
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 | |
if: always() | |
needs: | |
- build_matrix | |
- build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- run: gh run download ${{ vars.GITHUB_RUN_ID }} --dir public | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Move content from /public/main to public | |
run: | | |
mv public/main/* public/ | |
rm -rf public/main | |
- name: List files in public folder | |
run: ls -lR 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 |