|
| 1 | +name: Sibling dependency instant update |
| 2 | + |
| 3 | +# Triggered the moment a sibling ExaDev package this repo depends on publishes a new version -- the publishing repo own ci.yml sends this repository_dispatch event right after semantic-release completes, instead of waiting for Dependabot own daily scheduled scan to notice. Bumps the named dependency, opens a PR, and requests auto-merge -- the branch push and PR creation use the default GITHUB_TOKEN (an ordinary same-repo operation), but the final merge step mints and uses a GitHub App installation token instead, since GITHUB_TOKEN-authenticated pushes do not cascade into further workflow runs and that merge needs to trigger ci.yml and release normally. This workflow never pushes directly to main -- the PR still only merges once this repo own CI genuinely passes on it. Note: every repo in this family also enforces a minimumReleaseAge pnpm supply-chain gate (see pnpm-workspace.yaml) that CI own pnpm install --frozen-lockfile step respects unconditionally, with no per-package exceptions -- so a same-day sibling release still cannot actually pass CI (and therefore cannot merge) until that gate window has elapsed, regardless of how quickly this workflow opens the PR. |
| 4 | + |
| 5 | +on: |
| 6 | + repository_dispatch: |
| 7 | + types: [sibling-released] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + bump-and-open-pr: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 10 |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v7 |
| 19 | + - uses: pnpm/action-setup@v6 |
| 20 | + - uses: actions/setup-node@v7 |
| 21 | + with: |
| 22 | + node-version: "22" |
| 23 | + cache: pnpm |
| 24 | + - name: Bump the released dependency |
| 25 | + env: |
| 26 | + PACKAGE: ${{ github.event.client_payload.package }} |
| 27 | + VERSION: ${{ github.event.client_payload.version }} |
| 28 | + run: pnpm add "$PACKAGE@$VERSION" |
| 29 | + - name: Check whether anything actually changed |
| 30 | + id: diff |
| 31 | + run: | |
| 32 | + if git diff --quiet -- package.json pnpm-lock.yaml; then |
| 33 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 34 | + else |
| 35 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 36 | + fi |
| 37 | + - name: Commit and open a PR |
| 38 | + if: steps.diff.outputs.changed == 'true' |
| 39 | + id: pr |
| 40 | + env: |
| 41 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + PACKAGE: ${{ github.event.client_payload.package }} |
| 43 | + VERSION: ${{ github.event.client_payload.version }} |
| 44 | + run: | |
| 45 | + git config user.name "github-actions[bot]" |
| 46 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 47 | + branch="sibling-update/${PACKAGE}-${VERSION}" |
| 48 | + git checkout -b "$branch" |
| 49 | + git add package.json pnpm-lock.yaml |
| 50 | + git commit -m "build(deps): bump ${PACKAGE} to ${VERSION}" -m "Triggered instantly by the ${PACKAGE} release, via repository_dispatch, rather than waiting for the next daily Dependabot scan." |
| 51 | + git push origin "$branch" |
| 52 | + pr_url=$(gh pr create --title "build(deps): bump ${PACKAGE} to ${VERSION}" --body "Automatic dependency bump triggered instantly by the ${PACKAGE} release." --base main --head "$branch") |
| 53 | + echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT" |
| 54 | + - name: Generate a token for the merge |
| 55 | + if: steps.diff.outputs.changed == 'true' |
| 56 | + id: app-token |
| 57 | + uses: actions/create-github-app-token@v2 |
| 58 | + with: |
| 59 | + app-id: "4473709" |
| 60 | + private-key: ${{ secrets.AUTOMERGE_APP_PRIVATE_KEY }} |
| 61 | + - name: Enable auto-merge |
| 62 | + if: steps.diff.outputs.changed == 'true' |
| 63 | + env: |
| 64 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 65 | + run: gh pr merge --auto --rebase "${{ steps.pr.outputs.pr_url }}" |
0 commit comments