|
17 | 17 | bump-and-open-pr: |
18 | 18 | if: github.event_name == 'repository_dispatch' |
19 | 19 | runs-on: ubuntu-latest |
20 | | - timeout-minutes: 10 |
| 20 | + timeout-minutes: 35 |
21 | 21 | steps: |
22 | 22 | - uses: actions/checkout@v7 |
23 | 23 | - uses: pnpm/action-setup@v6 |
@@ -65,25 +65,30 @@ jobs: |
65 | 65 | 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") |
66 | 66 | echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT" |
67 | 67 | echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
68 | | - - name: Wait for this repo own real CI to register on the PR |
| 68 | + - name: Wait for all CI checks to pass, then rebase-merge |
69 | 69 | if: steps.diff.outputs.changed == 'true' |
70 | 70 | env: |
71 | 71 | GH_TOKEN: ${{ steps.app-token.outputs.token }} |
72 | 72 | run: | |
73 | | - for i in $(seq 1 30); do |
74 | | - found=$(gh api "repos/${{ github.repository }}/commits/${{ steps.pr.outputs.head_sha }}/check-runs" --jq '[.check_runs[] | select(.name == "Test")] | length') |
75 | | - if [ "$found" -gt 0 ]; then |
76 | | - echo "ci.yml own Test check has registered after $((i * 3))s" |
| 73 | + pr_url="${{ steps.pr.outputs.pr_url }}" |
| 74 | + head_sha="${{ steps.pr.outputs.head_sha }}" |
| 75 | + repo="${{ github.repository }}" |
| 76 | + for i in $(seq 1 90); do |
| 77 | + pending=$(gh api "repos/${repo}/commits/${head_sha}/check-runs" --paginate --jq '[.check_runs[] | select(.conclusion == null)] | length') |
| 78 | + if [ "$pending" -eq 0 ]; then |
| 79 | + failed=$(gh api "repos/${repo}/commits/${head_sha}/check-runs" --paginate --jq '[.check_runs[] | select(.conclusion != "success" and .conclusion != "skipped")] | length') |
| 80 | + if [ "$failed" -gt 0 ]; then |
| 81 | + echo "::error::CI checks failed on this sibling-update PR. Leaving it open for manual review." |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + echo "All CI checks passed. Rebase-merging." |
| 85 | + gh pr merge --rebase "$pr_url" |
77 | 86 | exit 0 |
78 | 87 | fi |
79 | | - sleep 3 |
| 88 | + echo "Waiting for ${pending} CI check(s) to complete..." |
| 89 | + sleep 20 |
80 | 90 | done |
81 | | - echo "::warning::ci.yml own Test check never registered after 90s -- proceeding anyway, but auto-merge may reject the PR as already clean or merge it immediately" >&2 |
82 | | - - name: Enable auto-merge |
83 | | - if: steps.diff.outputs.changed == 'true' |
84 | | - env: |
85 | | - GH_TOKEN: ${{ steps.app-token.outputs.token }} |
86 | | - run: gh pr merge --auto --rebase "${{ steps.pr.outputs.pr_url }}" |
| 91 | + echo "::warning::CI did not complete within 30 minutes. PR left open for manual merge." >&2 |
87 | 92 |
|
88 | 93 | heal-stranded-prs: |
89 | 94 | # gh pr merge --auto above only ever fires once, right after a PR opens. If enough other commits land on main before this repo's own CI finishes on that PR, the PR's branch falls behind and GitHub marks it CONFLICTING -- and a conflicting PR can never auto-merge, no matter how green its own CI is, with nothing to ever retry it. This job runs on every push to main (the only time a previously-clean PR can newly become conflicting) and regenerates any bump PR this same workflow opened that is now stuck: closes the stale PR/branch and re-runs the identical bump against the new main, rather than attempting a real git rebase -- a plain `pnpm add <package>@<version>` is fully idempotent and deterministic, so there is no conflict to resolve, only a fresh diff to produce. |
|
0 commit comments