bump-plugin-shas.yml 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. name: Bump Plugin SHAs
  2. # Nightly sweep: for each external entry whose upstream HEAD has moved past
  3. # its pinned SHA, validate at the new SHA with `claude plugin validate`
  4. # inline, then open one PR per bumped plugin on branch `bump/<slug>`.
  5. # Failing entries stay isolated in their own PR; passing bumps merge
  6. # independently.
  7. #
  8. # Bot-free — uses the default GITHUB_TOKEN. PRs opened with GITHUB_TOKEN don't
  9. # trigger on:pull_request workflows, so the required status checks on main
  10. # (`scan` from Scan Plugins, `check` from Check MCP URLs, `validate` from
  11. # Validate Plugins) would never run and the bump PR could never merge.
  12. # workflow_dispatch is exempt from that recursion guard, so we dispatch all
  13. # three ourselves against each per-entry bump branch after its PR is opened.
  14. # Each check run lands on the branch HEAD — the same SHA as the PR head — and
  15. # satisfies the corresponding required check. (Each of those workflows runs
  16. # its job unconditionally on workflow_dispatch, so a dispatch always reports.)
  17. #
  18. # max-bumps caps the per-night work for cost control. Per-entry scans are
  19. # more expensive than a single batched scan, so the cap is conservative.
  20. # The composite action skips entries that already have an open bump PR, so
  21. # re-dispatches don't pile up duplicate work.
  22. on:
  23. schedule:
  24. - cron: '23 7 * * *' # Daily 07:23 UTC
  25. workflow_dispatch:
  26. inputs:
  27. max_bumps:
  28. description: Cap on plugins bumped this run
  29. required: false
  30. default: '30'
  31. permissions:
  32. contents: write
  33. pull-requests: write
  34. actions: write # gh workflow run {scan-plugins,check-mcp-urls,validate-plugins}.yml per bump branch
  35. concurrency:
  36. group: bump-plugin-shas
  37. jobs:
  38. bump:
  39. runs-on: ubuntu-latest
  40. # Per-bump cost is ~2s (ls-remote + shallow clone + validate); 30 entries
  41. # is ~1-2 min. The 60 min ceiling absorbs slow upstreams without letting a
  42. # pathological run consume the default 360 min budget.
  43. timeout-minutes: 60
  44. steps:
  45. - uses: actions/checkout@v4
  46. # createCommitOnBranch-based bump so commits are signed by GitHub and
  47. # satisfy the org-level required_signatures ruleset on main.
  48. - uses: anthropics/claude-plugins-community/.github/actions/bump-plugin-shas@e2019b2a01f11aa1484c53540b1cfab5eebbc299
  49. id: bump
  50. with:
  51. marketplace-path: .claude-plugin/marketplace.json
  52. max-bumps: ${{ inputs.max_bumps || '30' }}
  53. pr-mode: per-entry
  54. claude-cli-version: latest
  55. # Per-entry fan-out: dispatch the three required checks against each bump
  56. # branch. `pr-urls` is a JSON array of {name, old_sha, new_sha, branch,
  57. # pr_url} entries emitted by the composite action when pr-mode is
  58. # per-entry. All three (scan / check / validate) are required on main and
  59. # none fire on the GITHUB_TOKEN-opened PR, so each must be dispatched.
  60. # A single failed dispatch (transient API error / rate limit) must not
  61. # strand the remaining branches, so we attempt every dispatch, then fail
  62. # the step if any failed: a missing required check would otherwise leave
  63. # its bump PR silently blocked behind a green run, and the composite
  64. # action skips slugs with an open PR so it would never be retried.
  65. - name: Dispatch required checks per per-entry PR
  66. if: steps.bump.outputs.pr-urls != '' && steps.bump.outputs.pr-urls != '[]'
  67. env:
  68. GH_TOKEN: ${{ github.token }}
  69. PR_URLS: ${{ steps.bump.outputs.pr-urls }}
  70. run: |
  71. set -euo pipefail
  72. dispatch_failures="$(mktemp)"
  73. jq -c '.[]' <<<"$PR_URLS" | while read -r entry; do
  74. branch=$(jq -r '.branch' <<<"$entry")
  75. name=$(jq -r '.name' <<<"$entry")
  76. for wf in scan-plugins check-mcp-urls validate-plugins; do
  77. echo "Dispatching ${wf}.yml against $branch ($name)"
  78. if ! gh workflow run "${wf}.yml" --ref "$branch"; then
  79. echo "::error::Failed to dispatch ${wf}.yml against $branch ($name) — required check will be missing; re-dispatch with: gh workflow run ${wf}.yml --ref $branch"
  80. echo "${wf} ${branch}" >> "$dispatch_failures"
  81. fi
  82. done
  83. done
  84. if [ -s "$dispatch_failures" ]; then
  85. echo "::error::$(wc -l < "$dispatch_failures" | tr -d ' ') required-check dispatch(es) failed; the affected bump PR(s) are blocked until re-dispatched (see annotations above)."
  86. exit 1
  87. fi