Skip to content

188 review search input #47

188 review search input

188 review search input #47

# Deploys each PR under its own subfolder
name: Deploy PR preview Storybook
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
concurrency: preview-${{ github.ref }}
jobs:
deploy-storybook-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Cache dependencies for packages/components
uses: actions/cache@v2
with:
path: packages/components/node_modules
key: ${{ runner.os }}-npm-packages-components-${{ hashFiles('packages/components/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-packages-components-
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Install and Build
run: |
npm ci
npm run build:storybook
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
id: preview
with:
source-dir: ./packages/components/storybook-static
token: ${{ secrets.GH_TOKEN }}
- name: Get preview URL
run: |
echo "Preview URL: ${{ steps.preview.outputs.deployment-url }}"
- name: Update comment in PR
uses: actions/github-script@v4
with:
script: |
const prNumber = context.payload.pull_request.number;
const {data: comments} = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const autoComment = comments.find(c => c.user.login === 'github-actions[bot]');
if (autoComment) {
const existingText = autoComment.body;
const newText = '\n- PR Preview URL for Storybook: ${{ steps.preview.outputs.deployment-url }}';
if (!existingText.includes(newText)) {
await github.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: autoComment.id,
body: `${existingText}\n${newText}`
});
}
}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}