Skip to content
19 changes: 7 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@ jobs:
needs: [publish]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
contents: write
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
Expand All @@ -172,11 +168,10 @@ jobs:
- name: Build Docs
run: yarn build:storybook:ci

- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: dist/storybook

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: dist/storybook
keep_files: true
enable_jekyll: false
55 changes: 47 additions & 8 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ on:
- synchronize
- closed

concurrency: preview-${{ github.ref }}
concurrency: preview-${{ github.event.number }}

permissions:
contents: write
pull-requests: write

jobs:
deploy-preview:
if: ${{ github.actor != 'dependabot[bot]' }}
if: ${{ github.event.action != 'closed' && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand Down Expand Up @@ -52,10 +56,45 @@ jobs:
- name: Build Docs
run: yarn build:storybook:ci

- name: Deploy preview
uses: rossjrw/pr-preview-action@9f77b1d057b494e662c50b8ca40ecc63f21e0887
- name: Deploy PR Preview
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: dist/storybook
destination_dir: pr-preview/pr-${{ github.event.number }}
keep_files: true
enable_jekyll: false

- name: Comment PR
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 **Preview deployed!**\n\n📖 [View Storybook Preview](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.number }}/)' })

cleanup-preview:
if: ${{ github.event.action == 'closed' && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout gh-pages
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
source-dir: dist/storybook
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
ref: gh-pages

- name: Remove PR preview
run: |
if [ -d "pr-preview/pr-${{ github.event.number }}" ]; then
rm -rf pr-preview/pr-${{ github.event.number }}
git config user.email ${{ secrets.GH_EMAIL }}
git config user.name ${{ secrets.GH_USER }}
git add .
git commit -m "Remove preview for PR #${{ github.event.number }}"
git push
else
echo "Preview directory not found, nothing to clean up"
fi