PR Preview #9115
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: PR Preview | |
| on: | |
| workflow_run: | |
| workflows: [PR Build] | |
| types: | |
| - completed | |
| permissions: | |
| actions: read | |
| statuses: write | |
| jobs: | |
| pr-preview: | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: haya14busa/action-workflow_run-status@v1 | |
| - name: Get PR Event | |
| id: get-pr-event | |
| uses: potiuk/get-workflow-origin@v1_5 | |
| with: | |
| token: ${{secrets.GITHUB_TOKEN}} | |
| sourceRunId: ${{github.event.workflow_run.id}} | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{steps.get-pr-event.outputs.sourceHeadBranch}} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Download Docs Artifact | |
| id: download-docs | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: docs | |
| path: dist | |
| run-id: ${{github.event.workflow_run.id}} | |
| github-token: ${{ github.token }} | |
| - name: Download Website Artifact | |
| id: download-website | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: website | |
| path: dist | |
| run-id: ${{github.event.workflow_run.id}} | |
| github-token: ${{ github.token }} | |
| - name: Download Coverage Artifact | |
| id: download-coverage | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: coverage | |
| path: dist/docs | |
| run-id: ${{github.event.workflow_run.id}} | |
| github-token: ${{ github.token }} | |
| - name: Check For Docs | |
| id: check-for-docs | |
| run: | | |
| if [ -d dist/docs ] && [ "$(ls -A dist/docs)" ]; then | |
| echo "found=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "found=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Check For Website | |
| id: check-for-website | |
| run: | | |
| if [ -d dist/website ] && [ "$(ls -A dist/website)" ]; then | |
| echo "found=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "found=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Deploy Storybook Preview | |
| if: ${{ steps.check-for-docs.outputs.found == 'true' }} | |
| timeout-minutes: 5 | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{secrets.NETLIFY_AUTH_TOKEN}} | |
| run: | | |
| cp netlify-storybook.toml netlify.toml | |
| npx netlify-cli@23.6.0 deploy --no-build --dir dist/docs --site ${{secrets.NETLIFY_SITE_NAME}} --alias ${{steps.get-pr-event.outputs.pullRequestNumber}} | |
| - name: Deploy Website Preview | |
| if: ${{ steps.check-for-website.outputs.found == 'true' }} | |
| timeout-minutes: 5 | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{secrets.NETLIFY_AUTH_TOKEN}} | |
| run: | | |
| cp netlify-website.toml netlify.toml | |
| npx netlify-cli@23.6.0 deploy --no-build --dir dist/website --site ${{secrets.NETLIFY_WEBSITE_SITE_NAME}} --alias ${{steps.get-pr-event.outputs.pullRequestNumber}} |