From 38e37d82308e63448ec2f6d88d757d6d4a893b4f Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Fri, 20 Nov 2026 20:24:42 -0500 Subject: [PATCH 1/5] ci: name the reusable CI caller job checks and dispatch CI from force-release --- .github/workflows/ci.yml | 2 +- .github/workflows/force-release.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 899dd5eab..d1691a62e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ permissions: contents: read jobs: - check: + checks: uses: systemfsoftware/systemfsoftware/.github/workflows/reusable-ci.yml@main with: commitlint: true diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index aeb6427d4..61fb26edc 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -19,6 +19,7 @@ on: - major permissions: + actions: write contents: write pull-requests: write @@ -62,3 +63,7 @@ jobs: --head "$BRANCH" \ --title "chore(release): force $BUMP" \ --body "Manually triggered ${BUMP} release (run ${{ github.run_id }}). Merging drops a dummy changeset intent on main; the Release workflow then opens the version-packages PR." + # A pull request opened with the workflow token starts its pull_request workflows in `action_required` with + # no jobs, so the required check is never emitted. A dispatched run is not gated that way and reports its + # checks on the branch head the pull request points at. + gh workflow run ci.yml --ref "$BRANCH" From 4ab4efb56d18cbddba7beaaa399b905bdaa1e45b Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Fri, 20 Nov 2026 20:31:44 -0500 Subject: [PATCH 2/5] ci(release): grant actions write to the dispatching job only and dispatch refs/heads --- .github/workflows/force-release.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index 61fb26edc..f3fb70e80 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -19,14 +19,17 @@ on: - major permissions: - actions: write - contents: write - pull-requests: write + contents: read jobs: force-release: name: dummy changeset + release PR runs-on: ubuntu-latest + # Only this job writes: it pushes the branch, opens the pull request and dispatches CI on the branch. + permissions: + actions: write + contents: write + pull-requests: write env: HUSKY: "0" steps: @@ -66,4 +69,4 @@ jobs: # A pull request opened with the workflow token starts its pull_request workflows in `action_required` with # no jobs, so the required check is never emitted. A dispatched run is not gated that way and reports its # checks on the branch head the pull request points at. - gh workflow run ci.yml --ref "$BRANCH" + gh workflow run ci.yml --ref "refs/heads/$BRANCH" From 366703137c09f7f93a9e61012473cbfbbbc327c1 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Fri, 20 Nov 2026 20:47:03 -0500 Subject: [PATCH 3/5] ci(release): approve the CI run a force-release pull request holds --- .github/workflows/force-release.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index f3fb70e80..99343229c 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -25,9 +25,7 @@ jobs: force-release: name: dummy changeset + release PR runs-on: ubuntu-latest - # Only this job writes: it pushes the branch, opens the pull request and dispatches CI on the branch. permissions: - actions: write contents: write pull-requests: write env: @@ -66,7 +64,21 @@ jobs: --head "$BRANCH" \ --title "chore(release): force $BUMP" \ --body "Manually triggered ${BUMP} release (run ${{ github.run_id }}). Merging drops a dummy changeset intent on main; the Release workflow then opens the version-packages PR." - # A pull request opened with the workflow token starts its pull_request workflows in `action_required` with - # no jobs, so the required check is never emitted. A dispatched run is not gated that way and reports its - # checks on the branch head the pull request points at. - gh workflow run ci.yml --ref "refs/heads/$BRANCH" + - name: Approve the CI run the pull request holds + env: + GH_TOKEN: ${{ github.token }} + run: | + # A pull request opened with the workflow token starts its pull_request workflows in `action_required` + # with no jobs, so the required check is never emitted until a run is approved. + sha=$(git rev-parse HEAD) + for _ in $(seq 1 12); do + id=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs?head_sha=$sha&event=pull_request" \ + --jq '[.workflow_runs[] | select(.conclusion == "action_required")][0].id // empty') + [ -n "$id" ] && break + sleep 5 + done + if [ -z "$id" ]; then + echo "No pull_request run is held on $sha." + exit 0 + fi + gh api --method POST "repos/$GITHUB_REPOSITORY/actions/runs/$id/approve" From 62385a1b1cce3dff1458758128731cf3a3272355 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Fri, 20 Nov 2026 20:52:50 -0500 Subject: [PATCH 4/5] ci(release): grant actions write so the job can approve the held CI run --- .github/workflows/force-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index 99343229c..a293ec98e 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -26,6 +26,7 @@ jobs: name: dummy changeset + release PR runs-on: ubuntu-latest permissions: + actions: write contents: write pull-requests: write env: From 1ff6cbaed58f3128e0595330e142eec3c803a1ca Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Fri, 20 Nov 2026 21:01:36 -0500 Subject: [PATCH 5/5] ci(release): approve the held CI run in a minimal downstream job that fails closed --- .github/workflows/force-release.yml | 61 +++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index a293ec98e..19d7f501a 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -25,8 +25,10 @@ jobs: force-release: name: dummy changeset + release PR runs-on: ubuntu-latest + outputs: + pr_number: ${{ steps.pr.outputs.number }} + head_sha: ${{ steps.pr.outputs.head_sha }} permissions: - actions: write contents: write pull-requests: write env: @@ -48,6 +50,7 @@ jobs: chore(release): force $BUMP release for $PACKAGE via workflow dispatch EOF - name: Commit, push, and open PR + id: pr env: GH_TOKEN: ${{ github.token }} BRANCH: force-release/${{ inputs.bump }}-${{ github.run_id }} @@ -60,26 +63,50 @@ jobs: git add .changeset git commit -m "chore(release): force $BUMP via workflow dispatch" git push origin "$BRANCH" - gh pr create \ + url=$(gh pr create \ --base "$BASE" \ --head "$BRANCH" \ --title "chore(release): force $BUMP" \ - --body "Manually triggered ${BUMP} release (run ${{ github.run_id }}). Merging drops a dummy changeset intent on main; the Release workflow then opens the version-packages PR." - - name: Approve the CI run the pull request holds - env: - GH_TOKEN: ${{ github.token }} + --body "Manually triggered ${BUMP} release (run ${{ github.run_id }}). Merging drops a dummy changeset intent on main; the Release workflow then opens the version-packages PR.") + # The pull request's own head commit, as GitHub reports it. + gh pr view "$url" --json number,headRefOid --jq '"number=\(.number)\nhead_sha=\(.headRefOid)"' >> "$GITHUB_OUTPUT" + + approve-ci: + name: approve the held CI run + needs: force-release + if: needs.force-release.outputs.pr_number != '' + runs-on: ubuntu-latest + permissions: + actions: write + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ needs.force-release.outputs.pr_number }} + HEAD_SHA: ${{ needs.force-release.outputs.head_sha }} + steps: + # A pull request opened with the workflow token starts its pull_request workflows in `action_required` with no + # jobs, so the required check is never emitted until a person or token with actions access approves the run. + # Fails closed: it succeeds only when every held run was approved or a run for the pull request already exists. + - name: Approve every pull_request run the pull request holds run: | - # A pull request opened with the workflow token starts its pull_request workflows in `action_required` - # with no jobs, so the required check is never emitted until a run is approved. - sha=$(git rev-parse HEAD) for _ in $(seq 1 12); do - id=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs?head_sha=$sha&event=pull_request" \ - --jq '[.workflow_runs[] | select(.conclusion == "action_required")][0].id // empty') - [ -n "$id" ] && break + runs=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs?head_sha=$HEAD_SHA&event=pull_request&per_page=100" \ + --jq "[.workflow_runs[] + | select(.head_repository.full_name == \"$GITHUB_REPOSITORY\" + and .actor.login == \"github-actions[bot]\" + and any(.pull_requests[]?; .number == ($PR_NUMBER | tonumber)))]") + held=$(jq -r '[.[] | select(.conclusion == "action_required") | .id] | .[]' <<< "$runs") + if [ -n "$held" ]; then + for id in $held; do + gh api --method POST "repos/$GITHUB_REPOSITORY/actions/runs/$id/approve" + echo "Approved run $id." + done + exit 0 + fi + if [ "$(jq 'length' <<< "$runs")" -gt 0 ]; then + echo "A pull_request run already exists for #$PR_NUMBER and none is held." + exit 0 + fi sleep 5 done - if [ -z "$id" ]; then - echo "No pull_request run is held on $sha." - exit 0 - fi - gh api --method POST "repos/$GITHUB_REPOSITORY/actions/runs/$id/approve" + echo "::error::No pull_request run was found for #$PR_NUMBER at $HEAD_SHA." + exit 1