From 72620a12c36796d2f0df2eac3692042f5c994efd Mon Sep 17 00:00:00 2001 From: edavidaja Date: Mon, 5 Oct 2026 12:14:46 -0400 Subject: [PATCH] ci: sync the example copy on Dependabot PRs Dependabot updates only _extensions/quarto-openapi, so the sync check fails on its PRs. A new workflow syncs the example, pushes the change to the PR branch, and dispatches the tests on the new commit. --- .github/workflows/sync-dependabot.yml | 46 +++++++++++++++++++++++++++ .github/workflows/test.yml | 2 ++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/sync-dependabot.yml diff --git a/.github/workflows/sync-dependabot.yml b/.github/workflows/sync-dependabot.yml new file mode 100644 index 0000000..591ec3f --- /dev/null +++ b/.github/workflows/sync-dependabot.yml @@ -0,0 +1,46 @@ +name: Sync example on Dependabot PRs + +# Dependabot updates only _extensions/quarto-openapi, so the example copy of +# the extension falls out of sync. This workflow copies the change into the +# example and pushes it to the PR branch. +# +# GitHub does not start workflows for pushes made with GITHUB_TOKEN, so the +# workflow then dispatches the tests on the PR branch. + +on: + pull_request: + branches: [main] + +permissions: + contents: write + actions: write + +jobs: + sync: + if: github.event.pull_request.user.login == 'dependabot[bot]' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ github.head_ref }} + - uses: actions/setup-node@v4 + with: + node-version: "24" + - run: npm run sync-example + - name: Push the synced example + id: push + run: | + if git diff --quiet; then + echo "pushed=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -am "chore: sync example copy of the extension" + git push + echo "pushed=true" >> "$GITHUB_OUTPUT" + - name: Run the tests on the synced commit + if: steps.push.outputs.pushed == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: gh workflow run test.yml --repo "$GITHUB_REPOSITORY" --ref "$GITHUB_HEAD_REF" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a63af95..b19d23b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,8 @@ on: branches: [main] pull_request: branches: [main] + # sync-dependabot.yml dispatches this after it pushes to a Dependabot PR. + workflow_dispatch: jobs: test: