From cf0e46e922f261cf350d49e019464836dd8f6e45 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 28 Mar 2026 03:44:43 +0100 Subject: [PATCH] Add CI workflow to trigger publishing on learn-latest-html-pages repo Triggers on successful completion of Sphinx Books Tests on main. Looks up the Sphinx Content Tests run ID for the same commit, then dispatches a repository_dispatch event to learn-latest-html-pages with both run IDs so artifacts can be retrieved. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/publish-learn-latest.yml | 35 ++++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish-learn-latest.yml b/.github/workflows/publish-learn-latest.yml index fed613aba..d14c4d65f 100644 --- a/.github/workflows/publish-learn-latest.yml +++ b/.github/workflows/publish-learn-latest.yml @@ -1,30 +1,47 @@ name: Publish learn-latest -on: [push] +on: + workflow_run: + workflows: ["Sphinx Books Tests"] + branches: [main] + types: [completed] jobs: trigger: runs-on: ubuntu-24.04 + if: ${{ github.event.workflow_run.conclusion == 'success' }} - strategy: - matrix: - python-version: ['3.12'] - node-version: [24.x] + # strategy: + # matrix: + # python-version: ['3.12'] + # node-version: [24.x] steps: - name: Trigger publishing on learn-latest repo + env: + TOKEN: ${{ secrets.LEARN_LATEST_TOKEN }} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + BOOKS_RUN_ID: ${{ github.event.workflow_run.id }} + SOURCE_REPO: ${{ github.repository }} run: | # Set the required variables repo_owner="AdaCore" repo_name="learn-latest-html-pages" event_type="trigger-workflow" service="publish-learn-latest" - version="${GITHUB_WORKFLOW_SHA}" - curl -L \ + # Look up the successful Sphinx Content Tests run ID for the same commit + content_run_id=$(curl -L --fail-with-body \ + -H "Authorization: Bearer $TOKEN" \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/$SOURCE_REPO/actions/workflows/sphinx-content-tests.js.yml/runs?head_sha=$HEAD_SHA&status=success&per_page=1" \ + | jq -r '.workflow_runs[0].id') + + curl -L --fail-with-body \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.LEARN_LATEST_TOKEN }}" \ + -H "Authorization: Bearer $TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$repo_owner/$repo_name/dispatches \ - -d "{\"event_type\": \"$event_type\", \"client_payload\": {\"service\": \"$service\", \"version\": \"$version\", \"unit\": false, \"integration\": true}}" + -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}}"