Skip to content

Commit 0ca7d34

Browse files
DEV: Attempt to get workflow to trigger on PR (#161)
Since we changed the validation workflow to trigger on pull_request_target, it will now be triggered automatically by the GitHub event that is fired when the create-pull-request action successfully opens a pull request. The manual repository_dispatch is no longer needed. Hopefully this works!
1 parent 9d2f5c7 commit 0ca7d34

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

.github/workflows/update_docs.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,3 @@ jobs:
9999
body: |
100100
Updates Documentation with changes from Discourse core
101101
102-
- name: Trigger validation
103-
if: steps.create-pr.outputs.pull-request-number
104-
run: |
105-
curl -X POST \
106-
-H "Accept: application/vnd.github.v3+json" \
107-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
108-
https://api.github.com/repos/${{ github.repository }}/dispatches \
109-
-d '{"event_type":"docs-updated","client_payload":{"branch":"update-documentation"}}'

.github/workflows/validate_pr.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
name: Validate PR Documentation
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [opened, synchronize, reopened]
66
paths:
77
- 'openapi.json'
8-
repository_dispatch:
9-
types: [docs-updated]
108

119
jobs:
1210
validate-openapi:
1311
runs-on: ubuntu-latest
1412
timeout-minutes: 10
1513

1614
steps:
17-
- name: Checkout PR
18-
if: github.event_name == 'pull_request'
15+
- name: Checkout PR Code
1916
uses: actions/checkout@v4
2017
with:
21-
fetch-depth: 0
22-
23-
- name: Checkout docs-updated branch
24-
if: github.event_name == 'repository_dispatch'
25-
uses: actions/checkout@v4
26-
with:
27-
ref: ${{ github.event.client_payload.branch }}
18+
# This is critical for pull_request_target. It ensures we checkout
19+
# the code from the PR, not the base branch.
20+
ref: ${{ github.event.pull_request.head.sha }}
21+
# fetch-depth: 0 is not strictly needed for validation, but kept it
22+
# in case your validation scripts need the full git history.
2823
fetch-depth: 0
2924

3025
- name: Start Swagger Validator

0 commit comments

Comments
 (0)