From c1807a7a757234d4428443a86c4dd11ce076ec5c Mon Sep 17 00:00:00 2001 From: Casey Manos <29509352+caseymanos@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:51:37 -0800 Subject: [PATCH 1/2] ci: send merged PRs to the docs sync webhook --- .github/workflows/docs-sync.yml | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/docs-sync.yml diff --git a/.github/workflows/docs-sync.yml b/.github/workflows/docs-sync.yml new file mode 100644 index 0000000..11fb788 --- /dev/null +++ b/.github/workflows/docs-sync.yml @@ -0,0 +1,35 @@ +name: Docs sync + +# Sends each merged PR to the Adapt docs sync automation, which opens a docs PR when one is needed. +on: + push: + branches: [main] + +permissions: + contents: read + pull-requests: read + +jobs: + notify: + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - name: Send the merged PR to the docs sync + env: + GH_TOKEN: ${{ github.token }} + SHA: ${{ github.sha }} + WEBHOOK_URL: ${{ secrets.DOCS_SYNC_WEBHOOK_URL }} + WEBHOOK_SECRET: ${{ secrets.DOCS_SYNC_WEBHOOK_SECRET }} + run: | + pr=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/pulls" \ + --jq '[.[] | select(.merged_at != null and .base.ref == "main")][0].number // empty') + if [ -z "$pr" ]; then + echo "No merged PR for $SHA." + exit 0 + fi + jq -n --arg repository "$GITHUB_REPOSITORY" --argjson pull_request "$pr" --arg sha "$SHA" \ + '{repository: $repository, pull_request: $pull_request, sha: $sha}' | + curl --fail-with-body --silent --show-error --request POST "$WEBHOOK_URL" \ + --header "Authorization: Bearer $WEBHOOK_SECRET" \ + --header "Content-Type: application/json" \ + --data @- From d8d0f7ff7f2d78fcbc6ef3b62f9be90cbce01d8f Mon Sep 17 00:00:00 2001 From: Casey Manos <29509352+caseymanos@users.noreply.github.com> Date: Tue, 17 Nov 2026 21:06:34 -0800 Subject: [PATCH 2/2] ci: send the docs sync the merged PR from its own event --- .github/workflows/docs-sync.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docs-sync.yml b/.github/workflows/docs-sync.yml index 11fb788..415061e 100644 --- a/.github/workflows/docs-sync.yml +++ b/.github/workflows/docs-sync.yml @@ -1,33 +1,28 @@ name: Docs sync # Sends each merged PR to the Adapt docs sync automation, which opens a docs PR when one is needed. +# pull_request_target gives the job the webhook secrets; it never checks out PR code. on: - push: + pull_request_target: + types: [closed] branches: [main] -permissions: - contents: read - pull-requests: read +permissions: {} jobs: notify: + if: github.event.pull_request.merged runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - name: Send the merged PR to the docs sync env: - GH_TOKEN: ${{ github.token }} - SHA: ${{ github.sha }} + PR: ${{ github.event.pull_request.number }} + SHA: ${{ github.event.pull_request.merge_commit_sha }} WEBHOOK_URL: ${{ secrets.DOCS_SYNC_WEBHOOK_URL }} WEBHOOK_SECRET: ${{ secrets.DOCS_SYNC_WEBHOOK_SECRET }} run: | - pr=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/pulls" \ - --jq '[.[] | select(.merged_at != null and .base.ref == "main")][0].number // empty') - if [ -z "$pr" ]; then - echo "No merged PR for $SHA." - exit 0 - fi - jq -n --arg repository "$GITHUB_REPOSITORY" --argjson pull_request "$pr" --arg sha "$SHA" \ + jq -n --arg repository "$GITHUB_REPOSITORY" --argjson pull_request "$PR" --arg sha "$SHA" \ '{repository: $repository, pull_request: $pull_request, sha: $sha}' | curl --fail-with-body --silent --show-error --request POST "$WEBHOOK_URL" \ --header "Authorization: Bearer $WEBHOOK_SECRET" \