|
1 | 1 | name: Publish learn-latest |
2 | 2 |
|
3 | | -on: [push] |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Sphinx Books Tests"] |
| 6 | + branches: [main] |
| 7 | + types: [completed] |
4 | 8 |
|
5 | 9 | jobs: |
6 | 10 | trigger: |
7 | 11 | runs-on: ubuntu-24.04 |
| 12 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
8 | 13 |
|
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] |
13 | 18 |
|
14 | 19 | steps: |
15 | 20 | - 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 }} |
16 | 26 | run: | |
17 | 27 | # Set the required variables |
18 | 28 | repo_owner="AdaCore" |
19 | 29 | repo_name="learn-latest-html-pages" |
20 | 30 | event_type="trigger-workflow" |
21 | 31 | service="publish-learn-latest" |
22 | | - version="${GITHUB_WORKFLOW_SHA}" |
23 | 32 |
|
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 \ |
25 | 42 | -X POST \ |
26 | 43 | -H "Accept: application/vnd.github+json" \ |
27 | | - -H "Authorization: Bearer ${{ secrets.LEARN_LATEST_TOKEN }}" \ |
| 44 | + -H "Authorization: Bearer $TOKEN" \ |
28 | 45 | -H "X-GitHub-Api-Version: 2022-11-28" \ |
29 | 46 | 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