Skip to content

ci: push changelog via deploy key, drop BOT_TOKEN dependency#79

Merged
duzos merged 3 commits into
masterfrom
ci/changelog-deploy-key
May 7, 2026
Merged

ci: push changelog via deploy key, drop BOT_TOKEN dependency#79
duzos merged 3 commits into
masterfrom
ci/changelog-deploy-key

Conversation

@duzos

@duzos duzos commented May 7, 2026

Copy link
Copy Markdown
Owner

About the PR

Follow-up to #77 and #78. The post-merge changelog workflow has been chasing a moving target: GITHUB_TOKEN is blocked by the PRS ONLY ruleset, fine-grained PATs don't carry team membership for ruleset bypass, and the built-in github-actions integration cannot be added as a bypass Integration actor (must be installed at org level). The ruleset already lists DeployKey (any) with bypass_mode: always, so this swaps to a deploy-key-driven push and removes this workflow's PAT dependency.

Why / Balance

No gameplay impact - CI only. Restores reliable post-merge changelog updates and removes a recurring failure mode tied to PAT lifetime.

Technical details

  • actions/checkout now uses ssh-key: ${{ secrets.CHANGELOG_DEPLOY_KEY }}. That single setting auths the clone over SSH and configures origin to use SSH, so the later git push origin HEAD:master rides the same key
  • Drop every BOT_TOKEN reference in .github/workflows/append_changelog.yml. The Python updater needs a token only to read PR metadata via /pulls/{n} and /pulls/{n}/commits, so it now reads secrets.GITHUB_TOKEN (which has full read for pull_request_target and workflow_dispatch)
  • Rename the env var to GH_TOKEN so the name reflects what's actually injected, with a matching update to scripts/update_changelog.py
  • Tighten the job's permissions: to contents: read + pull-requests: read - we no longer need write on the auto-issued token, the deploy key handles writes
  • Make pr_numbers required for manual dispatch - the script falls back to the event payload's pull_request field when the list is empty, which doesn't exist on workflow_dispatch events

.github/workflows/clear_changelog.yml still references BOT_TOKEN, but it triggers on PRs to a release branch that doesn't exist in this repo today, so it's dormant. Out of scope here; can migrate it the same way if/when release comes back.

Setup (out of band)

A repo deploy key named Changelog bot has been added with write access enabled, and its private half is stored as repo secret CHANGELOG_DEPLOY_KEY. The expired BOT_TOKEN PAT can be revoked once this lands.

Media

N/A - CI only.

Requirements

Breaking changes

None.

Backfill plan (post-merge)

gh workflow run "Update Changelog" --repo amblelabs/superhero -f pr_numbers="66,67,68,69,70,71,74,76,77,78"

PATs (fine- or coarse-grained) issued to bypass-team members were
the only way for the workflow to push past the PRS-ONLY ruleset,
and that came back to bite us when BOT_TOKEN expired. The ruleset
already allows any deploy key with bypass_mode:always, so swap to
that path:

  - actions/checkout uses ssh-key: CHANGELOG_DEPLOY_KEY, which
    auths the clone over SSH and configures origin for SSH push
  - the script reads PR metadata via secrets.GITHUB_TOKEN (the
    token has full read for pull_request_target and workflow_dispatch)
  - lock GITHUB_TOKEN to contents:read + pull-requests:read since
    we no longer need write
  - drop the https x-access-token push in favour of ssh-driven
    git push origin HEAD:master
Copilot AI review requested due to automatic review settings May 7, 2026 18:30
@duzos duzos added bug Something isn't working C: No Java Changes: Requires no Java knowledge to review or fix this item. labels May 7, 2026
@github-actions github-actions Bot added the S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. label May 7, 2026
@duzos duzos self-assigned this May 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the post-merge Update Changelog GitHub Actions workflow to push changelog commits using a repo deploy key (bypassing the PRS ONLY ruleset) and removes the dependency on a long-lived PAT for authentication.

Changes:

  • Switch actions/checkout to SSH auth via secrets.CHANGELOG_DEPLOY_KEY, so git push uses the deploy key.
  • Replace PAT usage with the run-scoped secrets.GITHUB_TOKEN for GitHub API reads needed by the changelog updater.
  • Add explicit job permissions (contents: read, pull-requests: read) since writes are no longer done via the workflow token.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/append_changelog.yml Outdated
was named BOT_TOKEN but now sourced from secrets.GITHUB_TOKEN -
misleading. rename the workflow env and the os.environ lookup in
the python updater so the name reflects what is actually injected.
@duzos duzos requested a review from drtheodor as a code owner May 7, 2026 18:34
@duzos duzos requested a review from Copilot May 7, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines 29 to 35
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
token: ${{ secrets.BOT_TOKEN }}
ssh-key: ${{ secrets.CHANGELOG_DEPLOY_KEY }}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scoped the description to clarify this PR drops BOT_TOKEN refs in append_changelog.yml. clear_changelog.yml still uses BOT_TOKEN but triggers on a release branch that doesn't exist today (no remote ref), so it's dormant - out of scope for this PR; happy to migrate it the same way when/if release comes back.

Comment on lines 49 to 52
run: |
python scripts/update_changelog.py \
--pr-numbers "${{ github.event.inputs.pr_numbers }}"
- name: Commit & push

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 08ed200 - made pr_numbers required: true on workflow_dispatch. Real bug; the script's fallback to ev["pull_request"] would KeyError on a manual run with no list. There's no sensible default for the manual path so this lets GitHub's input form reject empty submits before the script runs.

scripts/update_changelog.py falls back to reading the pull_request
field of the event payload when --pr-numbers is empty, but that
field doesn't exist for workflow_dispatch, so a manual run with no
PR list KeyErrors. there's no sensible default for the manual path,
so make the input required and let github reject empty submits.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@duzos duzos merged commit 604a8fe into master May 7, 2026
5 checks passed
@duzos duzos deleted the ci/changelog-deploy-key branch May 7, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working C: No Java Changes: Requires no Java knowledge to review or fix this item. S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants