Skip to content

Commit a919daa

Browse files
dlabajcursoragent
andcommitted
fix(CI): split documentation workflow to avoid pull_request_target checkout block
Rebased onto main and merged with the is-release workflow_call changes from #12598. PR builds use pull_request (artifact upload); deploy uses workflow_run. Closes #12601 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4d61988 commit a919daa

2 files changed

Lines changed: 89 additions & 9 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Documentation deploy
2+
on:
3+
workflow_run:
4+
workflows: [Documentation]
5+
types: [completed]
6+
jobs:
7+
deploy:
8+
name: Deploy
9+
runs-on: ubuntu-latest
10+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion != 'cancelled'
11+
env:
12+
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
13+
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
14+
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
15+
steps:
16+
- name: Check out project
17+
uses: actions/checkout@v4
18+
19+
- name: Set up project
20+
uses: ./.github/actions/setup-project
21+
with:
22+
skip-build: true
23+
24+
- name: Download PR number
25+
uses: actions/download-artifact@v4
26+
with:
27+
name: pr-number
28+
run-id: ${{ github.event.workflow_run.id }}
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Set PR number
32+
run: echo "GH_PR_NUM=$(cat pr-number.txt)" >> $GITHUB_ENV
33+
34+
- name: Download documentation
35+
uses: actions/download-artifact@v4
36+
with:
37+
name: documentation
38+
path: packages/react-docs/public
39+
run-id: ${{ github.event.workflow_run.id }}
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Download a11y coverage
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: a11y-coverage
46+
path: packages/react-docs/coverage
47+
run-id: ${{ github.event.workflow_run.id }}
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Upload documentation
51+
run: node .github/upload-preview.mjs packages/react-docs/public
52+
53+
- name: Upload accessibility results
54+
if: always()
55+
run: node .github/upload-preview.mjs packages/react-docs/coverage

.github/workflows/documentation.yml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Documentation
22
on:
3-
pull_request_target:
3+
pull_request:
44
issue_comment:
55
types: [created]
66
workflow_call:
@@ -19,6 +19,7 @@ on:
1919
required: true
2020
jobs:
2121
check-permissions:
22+
if: github.event_name == 'issue_comment'
2223
uses: patternfly/.github/.github/workflows/check-team-membership.yml@fdb52a63a2220ec8a3b6c2d43f312cda708ffa06
2324
secrets: inherit
2425

@@ -29,37 +30,61 @@ jobs:
2930
if: >-
3031
always() &&
3132
!cancelled() &&
32-
(inputs.is-release || needs.check-permissions.outputs.allowed == 'true')
33+
(inputs.is-release || github.event_name != 'issue_comment' || needs.check-permissions.outputs.allowed == 'true')
3334
env:
3435
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
3536
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
3637
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
3738
GH_PR_NUM: ${{ needs.check-permissions.outputs.pr-number }}
3839
steps:
3940
- name: Check out project from PR branch
40-
if: github.event_name == 'pull_request_target' || github.event_name == 'issue_comment'
41+
if: github.event_name == 'issue_comment'
4142
uses: actions/checkout@v4
4243
with:
43-
# Checkout the merge commit so that we can access the PR's changes.
44-
# This is nessesary because `pull_request_target` checks out the base branch (e.g. `main`) by default.
4544
ref: refs/pull/${{ env.GH_PR_NUM }}/head
4645

4746
- name: Check out project
48-
if: inputs.is-release || github.event_name == 'workflow_call'
47+
if: github.event_name != 'issue_comment'
4948
uses: actions/checkout@v4
49+
5050
- name: Set up and build project
5151
uses: ./.github/actions/setup-project
5252

5353
- name: Build documentation
5454
run: yarn build:docs
5555

56-
- name: Upload documentation
57-
if: always()
56+
- name: Upload documentation preview
57+
if: always() && !cancelled() && github.event_name != 'pull_request'
5858
run: node .github/upload-preview.mjs packages/react-docs/public
5959

6060
- name: Run accessibility tests
6161
run: yarn serve:docs & yarn test:a11y
6262

6363
- name: Upload accessibility results
64-
if: always()
64+
if: always() && !cancelled() && github.event_name != 'pull_request'
6565
run: node .github/upload-preview.mjs packages/react-docs/coverage
66+
67+
- name: Upload docs artifact
68+
if: always() && !cancelled() && github.event_name == 'pull_request'
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: documentation
72+
path: packages/react-docs/public
73+
74+
- name: Upload a11y artifact
75+
if: always() && !cancelled() && github.event_name == 'pull_request'
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: a11y-coverage
79+
path: packages/react-docs/coverage
80+
81+
- name: Save PR number
82+
if: always() && !cancelled() && github.event_name == 'pull_request'
83+
run: echo "${{ github.event.pull_request.number }}" > pr-number.txt
84+
85+
- name: Upload PR number
86+
if: always() && !cancelled() && github.event_name == 'pull_request'
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: pr-number
90+
path: pr-number.txt

0 commit comments

Comments
 (0)