From 9cb14fe4346b0d57e7674c02e44bddfab2d98bfb Mon Sep 17 00:00:00 2001 From: Katie Langerman Date: Thu, 10 Nov 2022 13:53:26 -0800 Subject: [PATCH] Add Storybook preview deploy button to PRs (#2567) * add deploy workflow Co-authored-by: Josh Black * add permissions * add unique id * words Co-authored-by: Josh Black --- .github/workflows/deploy_preview.yml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index a96ad4242ce..3881273c026 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -6,6 +6,9 @@ permissions: contents: read pages: write id-token: write + deployments: write + statuses: write + checks: write jobs: deploy-preview: @@ -26,3 +29,32 @@ jobs: install: npm ci && cd docs && npm ci && cd .. build: npm run build:docs:preview output_dir: docs/public + + deploy-storybook: + if: ${{ github.repository == 'primer/react' }} + name: Preview Storybook + runs-on: ubuntu-latest + needs: deploy-preview + steps: + - uses: chrnorm/deployment-action@v2.0.3 + name: Create GitHub deployment for storybook + id: storybook + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: storybook-preview-${{ github.event.number }} + environment_url: '${{ needs.deploy-preview.outputs.deployment_url }}/storybook' + - name: Update storybook deployment status (success) + if: success() + uses: chrnorm/deployment-status@v2.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}/storybook' + state: 'success' + deployment-id: ${{ steps.storybook.outputs.deployment_id }} + - name: Update storybook deployment status (failure) + if: failure() + uses: chrnorm/deployment-status@v2.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + state: 'failure' + deployment-id: ${{ steps.storybook.outputs.deployment_id }}