Update storybook monorepo to v8 (major) #12835
Workflow file for this run
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
name: Storybook Preview Publish | |
on: | |
workflow_dispatch: | |
pull_request: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write | |
name: Deploy to Cloudflare Pages | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
cache: "yarn" | |
- name: Install dependencies | |
run: yarn | |
- name: Run build | |
run: yarn build-storybook | |
env: | |
NODE_OPTIONS: "--max_old_space_size=6144" | |
- name: Publish | |
uses: cloudflare/pages-action@v1 | |
id: publish | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_SALT_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_SALT_ACCOUNT_ID }} | |
projectName: "saltdesignsystem-storybook" | |
directory: ./storybook-static | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.head_ref || github.ref_name }} | |
- name: Preview URL | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
if (context.eventName == 'pull_request') { | |
const previewUrl = "${{ steps.publish.outputs.url }}"; | |
const commentText = `Storybook Preview Link `; | |
const {data: comments} = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.number, | |
}); | |
const oldPreviewUrlComment = comments.find(comment => comment.body.includes(commentText)); | |
if (!oldPreviewUrlComment) { | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `${commentText} ${previewUrl}` | |
}); | |
} else { | |
github.rest.issues.updateComment({ | |
comment_id: oldPreviewUrlComment.id, | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `${commentText} ${previewUrl}` | |
}); | |
}; | |
} |