Skip to content

Commit a711f69

Browse files
DEV: Have workflow only run if it finds changes (#159)
We want to make sure the validate_pr workflow runs only if the update_docs workflow made a PR.
1 parent 51173fa commit a711f69

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎.github/workflows/update_docs.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
fi
8888
8989
- name: Create PR
90+
id: create-pr
9091
uses: peter-evans/create-pull-request@v5
9192
with:
9293
path: discourse_api_docs
@@ -97,3 +98,12 @@ jobs:
9798
author: discoursebuild <build@discourse.org>
9899
body: |
99100
Updates Documentation with changes from Discourse core
101+
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: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ on:
55
types: [opened, synchronize, reopened]
66
paths:
77
- 'openapi.json'
8-
workflow_run:
9-
workflows: ["Update Docs"]
10-
types: [completed]
11-
branches: [main]
8+
repository_dispatch:
9+
types: [docs-updated]
1210

1311
jobs:
1412
validate-openapi:
@@ -22,11 +20,11 @@ jobs:
2220
with:
2321
fetch-depth: 0
2422

25-
- name: Checkout workflow run
26-
if: github.event_name == 'workflow_run'
23+
- name: Checkout docs-updated branch
24+
if: github.event_name == 'repository_dispatch'
2725
uses: actions/checkout@v4
2826
with:
29-
ref: ${{ github.event.workflow_run.head_branch }}
27+
ref: ${{ github.event.client_payload.branch }}
3028
fetch-depth: 0
3129

3230
- name: Start Swagger Validator

0 commit comments

Comments
 (0)