Skip to content

ci(workflows): add least-privilege permissions to nightly.yaml and tag.yaml - #8055

Open
yhabib wants to merge 1 commit into
mainfrom
fix/nightly-tag-permissions
Open

ci(workflows): add least-privilege permissions to nightly.yaml and tag.yaml#8055
yhabib wants to merge 1 commit into
mainfrom
fix/nightly-tag-permissions

Conversation

@yhabib

@yhabib yhabib commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

.github/workflows/nightly.yaml and .github/workflows/tag.yaml declare no permissions: key. Both run with the default GITHUB_TOKEN, which is read and write for every scope. They only push a tag and publish a release.

This is part 2 of a 4-part split. The other parts give the same treatment to other workflow files.

Changes

  • Added a workflow-level contents: read block to nightly.yaml, and a job-level contents: write block to the tag-main job.
  • Added a workflow-level contents: write block to tag.yaml.

Tests

  • Ran ./scripts/fmt-yaml --check. It exits 0 with no output.
  • Ran actionlint 1.7.7 on both files, on main and on this branch. Both sides report zero findings.
  • Read every step of all three jobs, and every composite action they call (build_nns_dapp, release_nns_dapp, checkout_snsdemo, needs_success). Every GITHUB_TOKEN user works under the scope its job now gets.
  • Could not run the plan's push smoke test (push to a nightly branch, watch the Nightly Publication run, read the job setup log for the resolved token permissions, then delete the branch). The build stage could not push a branch, so this smoke test still needs to run before merge.

Todos

  • Accessibility (a11y) – any impact? No, this only changes GitHub Actions workflows.
  • Changelog – is it needed? No, a workflow permissions change is not user facing.
  • This is part 2 of 4, split from item 1788181556. The other parts land as their own pull requests: item 1788562415 (PR chore(ci): add least-privilege permissions to build.yml and checks.yml #8053), item 1788562417 (PR chore(ci): limit GITHUB_TOKEN to read-only in ten workflows #8054), and item 1788562418.
  • Item 1788562418 (the repository default token setting) must land last, after every other part.
  • Before merge: push this branch to a nightly branch, confirm the Nightly Publication run shows Contents: write for tag-main and Contents: read for nightly-passes in the job setup log, confirm the run is green, then delete the nightly branch.
  • After merge: confirm git ls-remote origin refs/tags/tip matches the merge commit, and confirm the next nightly-* tag has a public release.

Both workflows ran with the repository default GITHUB_TOKEN. That token
holds write access in every scope. Each workflow now names only the
scope that it needs.

nightly.yaml gets a workflow-level contents: read block. The tag-main
job gets a job-level contents: write block, because it pushes a
nightly-* tag and it publishes a release. The nightly-passes job
inherits read access only.

tag.yaml gets a workflow-level contents: write block. Its one job
pushes the tip tag.
@yhabib
yhabib requested a review from a team as a code owner September 5, 2026 00:17
@zeropath-ai

zeropath-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to e75f759.

Security Overview
Detected Code Changes
Change Type Relevant files
Configuration changes ► .github/workflows/nightly.yaml
    Add permissions: contents: read
► .github/workflows/nightly.yaml
    Update concurrency section to include permissions: contents: write
► .github/workflows/tag.yaml
    Add permissions: contents: write

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.

🟡 Changes recommended

The permissions change needs to be validated via an actual GitHub Actions run (as noted in the PR description) to confirm the jobs still succeed with the reduced token scopes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR tightens GitHub Actions GITHUB_TOKEN privileges for the repo’s tagging and nightly release workflows by explicitly setting permissions: so jobs don’t run with broad default write access.

Changes:

  • Add workflow-level permissions: contents: write to .github/workflows/tag.yaml to allow pushing the tip tag.
  • Add workflow-level permissions: contents: read to .github/workflows/nightly.yaml, and elevate only the tag-main job to contents: write for tag/release publication.
File summaries
File Description
.github/workflows/tag.yaml Grants contents: write so the workflow can push the tip tag.
.github/workflows/nightly.yaml Defaults to contents: read, raising only the tagging/release job to contents: write.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@yhabib

yhabib commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

This live run needs a real Nightly Publication run. Today's nightly release does not exist yet (checked 2026-09-05T00:26Z UTC). A run on the nightly branch before that release exists would push a real public release from this branch, not from main. I will not force that risk now. Sibling PR #8053 already proved both scope halves live (contents: write for a tag push and for release_nns_dapp), against the same composite actions this file calls. The live run of nightly.yaml itself stays in the PR Todos, to run once today's real nightly release exists.

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.

🟢 Approved

The changes are minimal, valid YAML, and the new permissions align with the workflows’ documented tag/release behavior without introducing functional code changes.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

2 participants