ci: Add PR comment #4
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 Publish' | |
on: | |
# TODO: Remove the push event before merging this PR | |
push: | |
branches: | |
- storybook | |
workflow_dispatch: | |
pull_request: | |
branches: "*" | |
paths: | |
- "*.stories.*" | |
jobs: | |
chromatic: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
cache: "npm" | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-modules- | |
- name: Install Dependencies | |
run: npm install | |
- name: Build & Publish Storybook | |
id: publish | |
uses: chromaui/action@v1 | |
with: | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
buildScriptName: "storybook-build" | |
# If the build is successful and the action is triggered by a PR, comment on the PR with the Chromatic URL | |
- name: PR Comment | |
if: github.event_name == 'pull_request' && steps.publish.outcome == 'success' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Changes published to Chromatic. Review at: ${steps.publish.outputs.storybookUrl}` | |
}) | |