Skip to content

Commit 6787bc6

Browse files
authored
Merge pull request #1334 from gusthoff/topic/infrastructure/github_actions/20260328/publish-learn-latest_github_commits
Add CI workflow to trigger publishing on learn-latest-html-pages repo
2 parents ef3b79b + cf0e46e commit 6787bc6

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,47 @@
11
name: Publish learn-latest
22

3-
on: [push]
3+
on:
4+
workflow_run:
5+
workflows: ["Sphinx Books Tests"]
6+
branches: [main]
7+
types: [completed]
48

59
jobs:
610
trigger:
711
runs-on: ubuntu-24.04
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
813

9-
strategy:
10-
matrix:
11-
python-version: ['3.12']
12-
node-version: [24.x]
14+
# strategy:
15+
# matrix:
16+
# python-version: ['3.12']
17+
# node-version: [24.x]
1318

1419
steps:
1520
- name: Trigger publishing on learn-latest repo
21+
env:
22+
TOKEN: ${{ secrets.LEARN_LATEST_TOKEN }}
23+
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
24+
BOOKS_RUN_ID: ${{ github.event.workflow_run.id }}
25+
SOURCE_REPO: ${{ github.repository }}
1626
run: |
1727
# Set the required variables
1828
repo_owner="AdaCore"
1929
repo_name="learn-latest-html-pages"
2030
event_type="trigger-workflow"
2131
service="publish-learn-latest"
22-
version="${GITHUB_WORKFLOW_SHA}"
2332
24-
curl -L \
33+
# Look up the successful Sphinx Content Tests run ID for the same commit
34+
content_run_id=$(curl -L --fail-with-body \
35+
-H "Authorization: Bearer $TOKEN" \
36+
-H "Accept: application/vnd.github+json" \
37+
-H "X-GitHub-Api-Version: 2022-11-28" \
38+
"https://api.github.com/repos/$SOURCE_REPO/actions/workflows/sphinx-content-tests.js.yml/runs?head_sha=$HEAD_SHA&status=success&per_page=1" \
39+
| jq -r '.workflow_runs[0].id')
40+
41+
curl -L --fail-with-body \
2542
-X POST \
2643
-H "Accept: application/vnd.github+json" \
27-
-H "Authorization: Bearer ${{ secrets.LEARN_LATEST_TOKEN }}" \
44+
-H "Authorization: Bearer $TOKEN" \
2845
-H "X-GitHub-Api-Version: 2022-11-28" \
2946
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
30-
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"service\": \"$service\", \"version\": \"$version\", \"unit\": false, \"integration\": true}}"
47+
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"service\": \"$service\", \"version\": \"$HEAD_SHA\", \"books_run_id\": \"$BOOKS_RUN_ID\", \"content_run_id\": \"$content_run_id\", \"source_repo\": \"$SOURCE_REPO\", \"unit\": false, \"integration\": true}}"

0 commit comments

Comments
 (0)