Skip to content

ci: open update-releases PRs with the release GitHub App token - #242

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
yashwanthkumarsuruneni:ci/update-releases-app-token
Nov 29, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
yashwanthkumarsuruneni:ci/update-releases-app-token

Conversation

@yashwanthkumarsuruneni

Copy link
Copy Markdown
Contributor

Opens the update-releases PRs with the oras-project-release-bot App token, so CI starts on them by itself, and keeps the App key away from npm ci. It also fixes the input injection from #237, as #238 proposes.

Closes #237
Closes #238

Changes

.github/workflows/update-releases.yml is split into two jobs, and the top-level permissions: is now {}:

  • update: no Environment, contents: read, checkout with persist-credentials: false.
    • Runs npm ci, the update script and npm run build, as before.
    • inputs.version now reaches the script as $INPUT_VERSION through env: (ci: update-releases interpolates workflow_dispatch input into shell #237).
    • When either output is set, it stages everything with git add -A and uploads git diff --cached --binary as the changes artifact (1-day retention). Staging first means files that are new in dist/ are included, and deleted files are removed. .gitignored build output is left out.
    • ADDED_VERSIONS and DEFAULT_VERSION become job outputs.
  • pr: needs: update, runs only when either output is non-empty, environment: release, permissions: {}.
    • Checks out with persist-credentials: false, downloads the artifact and runs git apply. No npm runs in this job.
    • Mints the token with actions/create-github-app-token, pinned to the same SHA oras-go uses (f418cff…, v3.4.0), with repositories: setup-oras, permission-contents: write and permission-pull-requests: write.
    • Runs create-pull-request with that token and an explicit author/committer. commit-message, title and body now read needs.update.outputs.*; the rest (sign-commits, signoff, branch, body text) is unchanged.

RELEASING.md gains a paragraph on the two jobs under "Automatic patch releases", and a "GitHub App" section next to "Deploy key". It covers what the App can do here, that RELEASE_APP_ID/RELEASE_APP_KEY live only in the main-only release Environment, that the App isn't a release-tags bypass actor, and that an org owner rotates the key.

Two changes from the issue's sketch:

  • Bot identity is looked up, not hardcoded. The author/committer identity is built from the token action's app-slug output and GET /users/{slug}[bot], instead of the literal oras-project-release-bot[bot] <362079208+…>. Upstream it resolves to that same value. It also keeps Signed-off-by matching the commit's real author if the App is ever replaced, and it let me test DCO on a fork with a different App.
  • The pr job checks out the run's commit, as update does, rather than naming main explicitly. The release Environment only deploys from main, so that commit is on main and the patch applies to the exact tree it was made from.

Testing

I tested on my fork yashwanthkumarsuruneni/setup-oras:

  • a test App with contents: write and pull_requests: write
  • a release Environment whose deployment branches are main only
  • "Allow GitHub Actions to create and approve pull requests" off

To give the workflow something to add, fork main had one extra fork-only commit that drops CLI 1.4.0 from releases.json and sets the action.yml default back to 1.3.6.

Done-when item Result
Dispatch from main opens a PR authored by the bot run → PR #2 by oras-release-test-5f939a[bot]: adds 1.4.0 back and bumps the default to 1.4.0
Its commit shows as Verified verified: true (valid); Signed-off-by matches the commit author (the App bot)
CI starts without anyone triggering it Tests, Check dist/ and License Checker started on the PR with the bot as actor; Tests and Check dist/ passed (DCO isn't installed on my fork, so I checked the sign-off by hand as above)
Dispatch from another branch fails at the Environment gate run: update ran, pr refused with Branch "gate-test" is not allowed to deploy to release due to environment protection rules

actionlint (with shellcheck) passes on the workflow.

Not covered: a run where the rebuild changes dist/. My fork-only commit didn't rebuild dist/, so the rebuilt bundle was identical and the patch only touched releases.json and action.yml. The patch handling is the same either way. The first real CLI release after this merges will exercise it, and check-dist will catch any mismatch.

After this merges, #240 can turn off "Allow GitHub Actions to create and approve pull requests".

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@TerryHowe

Copy link
Copy Markdown
Member

Thanks! This is approved and all checks pass, but it can't be merged yet: main requires signed commits, and 52203bf shows as unsigned.

The easiest way to sign is with an SSH key:

  1. Add your SSH public key on GitHub as a Signing Key, under https://github.com/settings/ssh/new with "Key type: Signing Key". Your existing authentication key works, but it has to be added again as a signing key.

  2. Tell git to sign with it:

    git config --global gpg.format ssh
    git config --global user.signingkey ~/.ssh/id_ed25519.pub
    git config --global commit.gpgsign true
  3. Re-sign the commit (keeping the sign-off) and force-push:

    git checkout ci/update-releases-app-token
    git commit --amend --no-edit -S --signoff
    git push --force-with-lease origin ci/update-releases-app-token

Afterwards, the commit should show a Verified badge. If it doesn't, check that the email in git config user.email is a verified email on your GitHub account (the noreply address you're using is fine).

Split update-releases.yml into two jobs. 'update' runs npm ci, the
update script and the build with a read-only token and no Environment,
and uploads the result as a patch. 'pr' applies the patch and opens the
PR with a token minted from the release App in the main-only release
Environment, so CI starts on the bot's PRs and the App key never shares
a job with third-party package code.

The author and committer are set to the App's bot identity so the
Signed-off-by trailer matches the commit. inputs.version is passed to
the script through env instead of being expanded into the shell.

Closes oras-project#237
Closes oras-project#238

Signed-off-by: Yash <20724658+yashwanthkumarsuruneni@users.noreply.github.com>
@TerryHowe
TerryHowe merged commit 7aff136 into oras-project:main Nov 29, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: open update-releases PRs with the release GitHub App token ci: update-releases interpolates workflow_dispatch input into shell

2 participants