fix(CI): split documentation workflow to avoid pull_request_target checkout block #5076
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: Documentation | |
| on: | |
| pull_request: | |
| issue_comment: | |
| types: [created] | |
| workflow_call: | |
| inputs: | |
| is-release: | |
| description: Whether this is invoked from the Release workflow (skip PR permission gating). | |
| type: boolean | |
| required: false | |
| default: false | |
| secrets: | |
| SURGE_LOGIN: | |
| required: true | |
| SURGE_TOKEN: | |
| required: true | |
| GH_PR_TOKEN: | |
| required: true | |
| jobs: | |
| check-permissions: | |
| if: github.event_name == 'issue_comment' | |
| uses: patternfly/.github/.github/workflows/check-team-membership.yml@fdb52a63a2220ec8a3b6c2d43f312cda708ffa06 | |
| secrets: inherit | |
| deploy: | |
| name: Build, test & deploy | |
| runs-on: ubuntu-latest | |
| needs: check-permissions | |
| if: >- | |
| always() && | |
| !cancelled() && | |
| (inputs.is-release || github.event_name != 'issue_comment' || needs.check-permissions.outputs.allowed == 'true') | |
| env: | |
| SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }} | |
| SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} | |
| GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }} | |
| GH_PR_NUM: ${{ needs.check-permissions.outputs.pr-number }} | |
| steps: | |
| - name: Check out project from PR branch | |
| if: github.event_name == 'issue_comment' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: refs/pull/${{ env.GH_PR_NUM }}/head | |
| - name: Check out project | |
| if: github.event_name != 'issue_comment' | |
| uses: actions/checkout@v4 | |
| - name: Set up and build project | |
| uses: ./.github/actions/setup-project | |
| - name: Build documentation | |
| run: yarn build:docs | |
| - name: Upload documentation preview | |
| if: always() && !cancelled() && github.event_name != 'pull_request' | |
| run: node .github/upload-preview.mjs packages/react-docs/public | |
| - name: Run accessibility tests | |
| run: yarn serve:docs & yarn test:a11y | |
| - name: Upload accessibility results | |
| if: always() && !cancelled() && github.event_name != 'pull_request' | |
| run: node .github/upload-preview.mjs packages/react-docs/coverage | |
| - name: Upload docs artifact | |
| if: always() && !cancelled() && github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: documentation | |
| path: packages/react-docs/public | |
| - name: Upload a11y artifact | |
| if: always() && !cancelled() && github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: a11y-coverage | |
| path: packages/react-docs/coverage | |
| - name: Save PR number | |
| if: always() && !cancelled() && github.event_name == 'pull_request' | |
| run: echo "${{ github.event.pull_request.number }}" > pr-number.txt | |
| - name: Upload PR number | |
| if: always() && !cancelled() && github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-number | |
| path: pr-number.txt |