Deploy PR to Netlify #133
This file contains hidden or 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: Deploy PR to Netlify | |
| on: | |
| workflow_run: | |
| workflows: ["Build pull request"] | |
| types: [completed] | |
| jobs: | |
| deploy-pull-request: | |
| name: "Deploy pull request" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - name: Download pr number | |
| uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 | |
| with: | |
| workflow: ${{ github.event.workflow.id }} | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: pr | |
| - name: Output pr number | |
| id: pr | |
| run: echo "id=$(<pr.txt)" >> $GITHUB_OUTPUT | |
| - name: Download artifact | |
| uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 | |
| with: | |
| workflow: ${{ github.event.workflow.id }} | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: preview | |
| path: storybook-static | |
| - name: Deploy to Netlify | |
| id: netlify | |
| uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 | |
| with: | |
| publish-dir: storybook-static | |
| deploy-message: "Deploy PR ${{ steps.pr.outputs.id }} SB" | |
| alias: ${{ steps.pr.outputs.id }} | |
| # These don't work because we're in workflow_run | |
| enable-pull-request-comment: false | |
| enable-commit-comment: false | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_PR_FOLDS }} | |
| timeout-minutes: 1 | |
| - name: Comment preview on PR | |
| uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b | |
| env: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| pr-number: ${{ steps.pr.outputs.id }} | |
| comment-tag: ${{ steps.pr.outputs.id }} | |
| message: | | |
| Preview: ${{ steps.netlify.outputs.deploy-url }} | |
| ⚠️ Exercise caution. Use test accounts. ⚠️ |