feat: publish storybook in PRs & master #5
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: Publish Storybook | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
storybook: | |
name: Storybook | |
runs-on: ubuntu-latest | |
env: | |
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
- name: Install dependencies | |
working-directory: ui | |
run: npm install | |
- name: Build | |
working-directory: ui | |
run: | | |
npm run build-storybook -- -o storybook-static/storybook | |
- name: Auth to Google Cloud | |
id: auth | |
if: ${{ always() && env.GOOGLE_SERVICE_ACCOUNT != 0 }} | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: "${{ secrets.GOOGLE_SERVICE_ACCOUNT }}" | |
- name: "Set up Cloud SDK" | |
if: env.GOOGLE_SERVICE_ACCOUNT != 0 | |
uses: "google-github-actions/setup-gcloud@v2" | |
- name: Publish storybook to Google Cloud | |
working-directory: ui | |
if: github.event.pull_request.number | |
run: | | |
gsutil -m rsync -d -r storybook-static/storybook gs://internal-kestra-host/${{ format('{0}/{1}', github.repository, github.head_ref) }} | |
# Comment or update comment on the PR | |
- name: Create a comment on the Pull Request | |
uses: thollander/actions-comment-pull-request@v3 | |
if: github.event.pull_request.number | |
with: | |
message: | | |
Storybook published on ${{ github.event.repository.updated_at }} | |
https://internal.dev.kestra.io/${{ github.event.repository.name }}/${{ github.head_ref }}/storybook | |
comment-tag: 'storybook' | |
- name: Publish storybook to Google Cloud | |
working-directory: ui | |
if: ${{ !github.event.pull_request.number }} | |
run: | | |
gsutil -m rsync -d -r storybook-static/storybook gs://internal-kestra-host/${{ format('{0}/{1}', github.repository, github.ref_name) }} | |
- name: Create commit comment | |
uses: peter-evans/commit-comment@v3 | |
if: ${{ !github.event.pull_request.number }} | |
with: | |
body: | | |
Storybook published on ${{ github.event.repository.updated_at }} | |
https://internal.dev.kestra.io/${{ github.event.repository.name }}/${{ github.ref_name }}/storybook | |
reactions: 'hooray' | |
- name: Setup Details URL | |
uses: LouisBrunner/[email protected] | |
if: ${{ always() && github.event.pull_request.number }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Publish Storybook | |
conclusion: ${{ job.status }} | |
output: | | |
{ | |
"summary":"Storybook published on ${{ github.event.repository.updated_at }}", | |
"details_url":"https://internal.dev.kestra.io/${{ github.event.repository.name }}/${{ github.head_ref }}/storybook" | |
} | |