Skip to content

Commit 22480fc

Browse files
authored
ci(bump): sign bump commits by creating them through the API (#5)
## Summary Bump commits were pushed with plain `git`, so they landed on `main` unsigned. We want every commit on `main` to show as verified, and commits created through the GitHub API are signed by GitHub. ## What Changed - The bump step now creates its commit with the `createCommitOnBranch` GraphQL mutation instead of `git commit` and `git push`. - The mutation sends the new `marketplace.json` contents and uses the current head of `main` as `expectedHeadOid`. - If `main` moved during the run, the API refuses the commit, the step fails with an error, and the next daily run retries. - Checkout no longer persists credentials. `BUMP_TOKEN` is only passed to the commit step, with no fallback to `github.token`. - The README section on the pin describes the new flow. ## Notes for reviewers - There's no automated test for a workflow change. A manual `workflow_dispatch` run after a new release is the way to check it, and the resulting commit should show as verified. Signed-off-by: igorjs <2278164+igorjs@users.noreply.github.com>
1 parent 540f116 commit 22480fc

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

‎.github/workflows/bump.yml‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2424
with:
2525
ref: main
26-
token: ${{ secrets.BUMP_TOKEN || github.token }}
26+
persist-credentials: false
2727

2828
- name: Find the latest release
2929
id: release
@@ -64,15 +64,29 @@ jobs:
6464
if: steps.release.outputs.outdated == 'true'
6565
run: shell/check-marketplace.sh
6666

67-
- name: Commit and push
67+
- name: Commit the bump through the API so GitHub signs it
6868
if: steps.release.outputs.outdated == 'true'
6969
env:
70+
GH_TOKEN: ${{ secrets.BUMP_TOKEN }}
71+
REPO: ${{ github.repository }}
7072
VERSION: ${{ steps.release.outputs.latest }}
73+
FILE_PATH: .claude-plugin/marketplace.json
7174
run: |
7275
set -euo pipefail
73-
git config user.name "github-actions[bot]"
74-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
75-
git add .claude-plugin/marketplace.json
76-
git commit -m "playbook ${VERSION}"
77-
git pull --rebase origin main
78-
git push origin HEAD:main
76+
head="$(gh api "repos/${REPO}/git/ref/heads/main" --jq .object.sha)"
77+
jq -n \
78+
--arg repo "$REPO" --arg head "$head" --arg msg "playbook ${VERSION}" \
79+
--arg path "$FILE_PATH" --arg content "$(base64 < "$FILE_PATH" | tr -d '\n')" \
80+
'{query: "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } } }",
81+
variables: {input: {
82+
branch: {repositoryNameWithOwner: $repo, branchName: "main"},
83+
message: {headline: $msg},
84+
expectedHeadOid: $head,
85+
fileChanges: {additions: [{path: $path, contents: $content}]}
86+
}}}' > "$RUNNER_TEMP/payload.json"
87+
oid="$(gh api graphql --input "$RUNNER_TEMP/payload.json" --jq '.data.createCommitOnBranch.commit.oid // empty')"
88+
if [ -z "$oid" ]; then
89+
echo "::error::the API did not create the commit. main may have moved since this run started. The next run retries." >&2
90+
exit 1
91+
fi
92+
echo "Created signed commit ${oid}."

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The plugin installs over HTTPS, so no SSH keys are needed.
1717

1818
## Keeping the pin current
1919

20-
The playbook entry points at the release archive `playbook-plugin-<version>.zip` and pins its sha256. The `bump` workflow runs daily at 06:37 UTC and can be started by hand. If `pragmatic-engineer/playbook` has a newer release, it runs `shell/bump-marketplace.sh`. The script downloads the archive, verifies its build provenance attestation, and writes the URL and the sha256 of those exact bytes. The workflow then runs `shell/check-marketplace.sh` and pushes the commit to `main` with the `BUMP_TOKEN` secret, a fine-grained token with `contents: write` on this repo. `main` is protected, so the secret must belong to an admin. Don't edit the pin by hand.
20+
The playbook entry points at the release archive `playbook-plugin-<version>.zip` and pins its sha256. The `bump` workflow runs daily at 06:37 UTC and can be started by hand. If `pragmatic-engineer/playbook` has a newer release, it runs `shell/bump-marketplace.sh`. The script downloads the archive, verifies its build provenance attestation, and writes the URL and the sha256 of those exact bytes. The workflow then runs `shell/check-marketplace.sh` and creates the commit on `main` through the GitHub API with the `BUMP_TOKEN` secret, a fine-grained token with `contents: write` on this repo. GitHub signs that commit, so it shows as verified. `main` is protected, so the secret must belong to an admin. Don't edit the pin by hand.
2121

2222
## License
2323

0 commit comments

Comments
 (0)