chore: consistent height with empty rows #92
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 | |
on: | |
pull_request: | |
branches: [main] | |
paths: | |
- "apps/admin-panel/**" | |
push: | |
branches: [main] | |
paths: | |
- "apps/admin-panel/**" | |
jobs: | |
storybook-preview: | |
name: Storybook Preview | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@v4 | |
- name: Run the Magic Nix Cache | |
uses: DeterminateSystems/magic-nix-cache-action@v8 | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build Storybook | |
run: nix develop -c make build-storybook-admin-panel | |
- name: Install Netlify CLI | |
run: npm install -g netlify-cli | |
- name: Deploy to Netlify (Pull Request) | |
id: netlify_deploy | |
if: github.event_name == 'pull_request' | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: 8f3d8282-da53-4b6d-8d3c-708c7d7030c9 | |
run: | | |
GITHUB_SHA="${{ github.sha }}" | |
SHORT_SHA="${GITHUB_SHA::7}" | |
ALIAS="pr-${{ github.event.pull_request.number }}-commit-${SHORT_SHA}" | |
netlify deploy \ | |
--dir=apps/admin-panel/storybook-static \ | |
--site=$NETLIFY_SITE_ID \ | |
--auth=$NETLIFY_AUTH_TOKEN \ | |
--alias="$ALIAS" \ | |
--message="Storybook Preview for PR #${{ github.event.pull_request.number }} Commit $GITHUB_SHA" \ | |
--json > deploy-info.json | |
DEPLOY_URL=$(jq -r '.deploy_url' deploy-info.json) | |
echo "deploy_url=$DEPLOY_URL" >> $GITHUB_OUTPUT | |
- name: Deploy to Netlify (Push to Main) | |
if: github.event_name == 'push' | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: 8f3d8282-da53-4b6d-8d3c-708c7d7030c9 | |
run: | | |
netlify deploy \ | |
--prod \ | |
--dir=apps/admin-panel/storybook-static \ | |
--site=$NETLIFY_SITE_ID \ | |
--auth=$NETLIFY_AUTH_TOKEN \ | |
--message="Storybook Build for Commit ${{ github.sha }}" \ | |
--json > deploy-info.json | |
DEPLOY_URL=$(jq -r '.deploy_url' deploy-info.json) | |
echo "deploy_url=$DEPLOY_URL" >> $GITHUB_OUTPUT | |
- name: Create or Update Preview Comment | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const prNumber = context.payload.pull_request.number; | |
const deployUrl = '${{ steps.netlify_deploy.outputs.deploy_url }}'; | |
const commentBody = `<!-- Storybook Preview Comment -->\nStorybook preview: [Link to Storybook](${deployUrl})`; | |
// Fetch existing comments on the PR | |
const { data: comments } = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: prNumber, | |
}); | |
// Identify if the bot has already made a comment | |
const botLogin = 'github-actions[bot]' | |
const existingComment = comments.find( | |
comment => comment.user.login === botLogin && comment.body.includes('<!-- Storybook Preview Comment -->') | |
); | |
if (existingComment) { | |
// Update the existing comment | |
await github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: existingComment.id, | |
body: commentBody, | |
}); | |
} else { | |
// Create a new comment | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: prNumber, | |
body: commentBody, | |
}); | |
} |