Skip to content

Publish from a job of its own, so pull request jobs have no write token - #233

Merged
Mpdreamz merged 3 commits into
feature/assembly-differfrom
feature/split-publish
Nov 25, 2026
Merged

Mpdreamz merged 3 commits into
feature/assembly-differfrom
feature/split-publish

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Pull request jobs no longer hold a write token or the publishing secrets: the publish steps of ci.yml move into a job of their own that runs for a push to main and for a tag only.

Prompt summary: After reviewing the permissions of the pull request checks in #232, the owner asked for the remaining finding to be fixed: the build job ran pull request code, and a third-party action, with contents, issues and packages write, only because the publish steps shared it. The change is its own pull request, apart from the API onboarding.

Why

The build job builds and tests the pull request, runs MSBuild tasks and source generators from its dependencies, and runs the assembly-differ action. It also pushed the canary and release packages, so it held contents, issues and packages write for every run, including pull requests from branches of this repository. A compromised dependency or action in that job could write to the repository's releases and packages.

What

A publish job

publish has needs: build and if: github.event_name == 'push'. It holds contents, issues and packages write, and is the only job that names FEEDZ_IO_API_KEY, NUGET_ORG_API_KEY or the token for the release. It checks out the same commit, fetches the tags, restores the tools, and runs the same push steps with the same conditions as before: canary packages to GitHub Packages and feedz.io for a push to a branch; release notes, the GitHub release and nuget.org for a tag.

What it publishes

The build job already built, tested and validated the packages. On a push it uploads build/output/*.nupkg as an artifact that expires after a day, and publish downloads it into build/output. The packages that are pushed are the ones that were tested, not a rebuild.

Build job permissions

build now has contents: read and pull-requests: write, the comment and labels of the API step. zizmor finds nothing about permissions or secrets in ci.yml; the remaining findings are the actions/* tags that policy allows and three trusted-publishing notes.

Risk: the publish steps only run for a push to main and for a tag, so a pull request cannot run them. I ran the hand-off on this pull request with a temporary commit, since reverted: both .nupkg files reached build/output in the publish job, which restored the tools and generated release notes. The pushes themselves first run when this merges, as canary packages from main, and the release steps with the next tag. A failed canary run only needs a rerun.

Stack: 2 of 2, on top of #232; retarget it to main once that merges.

Verify

git diff feature/assembly-differ -- .github/workflows/ci.yml

In the run of this pull request, the build job's "GITHUB_TOKEN Permissions" show Contents: read and PullRequests: write, and the publish job does not run.

🤖 Generated with Claude Code

Mpdreamz and others added 2 commits November 25, 2026 16:35
The build job runs pull request code and the third-party API action, and
held contents, issues and packages write only because the publish steps
shared it. It now reads contents and writes pull-requests for the API
comment. A publish job, which runs for a push to main and for a tag only,
takes the packages the build job built and validated, and holds the write
permissions and the publishing secrets.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Mpdreamz Mpdreamz added the Infra Build and repository infrastructure label Nov 25, 2026
@github-actions

Copy link
Copy Markdown

API changes: suggested version change None

✅ All good: the public API is unchanged.

  • ✅ Elastic.Transport.dll: no changes
  • ✅ Elastic.Transport.VirtualizedCluster.dll: no changes

Public API files

✅ The committed API files match the build (6 files).

The hand-off was verified on a pull request: the build job's packages
reached the publish job in build/output, which restored the tools and
generated release notes. The publish job runs for a push or a tag again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Mpdreamz
Mpdreamz marked this pull request as ready for review November 25, 2026 15:49
@Mpdreamz
Mpdreamz merged commit 0641db3 into feature/assembly-differ Nov 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Infra Build and repository infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant