Repository navigation
ci(workflows): harden update workflows - #215
Conversation
Make the `unstable` environment unconditional in all three update workflows so branch protection always applies, even on manual triggers from other refs. - Set `environment.name` to `unstable` unconditionally; the previous conditional expression could bypass the environment when triggered from a non-default ref. - Fix `nixpkgs-keys` to use `nixpkgs` only; `nixpkgs-unstable` is the channel the input follows, not a separate flake input name. - Add `NIX_FLAKE_CHECKER_NO_TELEMETRY: "true"` env var; at the pinned v13 SHA, `send-statistics: false` maps to `=false`, not `=true`, so the env override is required to suppress telemetry. - Add `persist-credentials: false` and `fetch-depth: 0` on checkout; prevents the default `GITHUB_TOKEN` from being stored in git config so that subsequent pushes must use the explicit App token URL. - Push via `https://x-access-token` URL in update scripts so commits use the GitHub App identity and trigger downstream workflows. - Use `--json number --jq '.number'` in `gh pr create`; removes fragile URL stripping with `##*/`. - Change `--base main` to `--base unstable` in PR creation calls. - Replace `git switch --create` with `git switch --force-create` so repeated runs succeed when the branch already exists. - Add `nix flake check` after `nix flake update` in the update-nix-flake-lock script to validate the flake before commit. - Fix Display Pull Request Link step: both expressions now reference `steps.update-nix-flake-lock` instead of `steps.update-flake-lock`. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Unsupported GitHub CLI flags break pull request creation, and one workflow still uses the default GitHub token.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Hardens automated dependency-update workflows and standardizes updates against unstable.
Changes:
- Enforces the protected environment and disables persisted credentials.
- Uses App-authenticated pushes and validates Nix updates.
- Corrects flake-checker and pull request handling configuration.
File summaries
| File | Description |
|---|---|
.github/workflows/update-terraform-binary-version.yaml |
Hardens Terraform update automation. |
.github/workflows/update-nix-flake-lock.yml |
Revises custom flake-lock updates. |
.github/workflows/update-flake-lock.yml |
Hardens action-based flake updates. |
Review details
Suppressed comments (4)
.github/workflows/update-terraform-binary-version.yaml:122
- This base option only affects newly created pull requests. The earlier existing-pull-request path finds a pull request against any base and edits only its title and body, so an open updater pull request against
mainwill remain there indefinitely. Also update the existing pull request's base tounstable.
--base unstable \
.github/workflows/update-nix-flake-lock.yml:109
- This base option only affects newly created pull requests. The existing-pull-request path accepts a pull request against any base and exits without changing it, so an open updater pull request against
mainwill remain there indefinitely. Update its base tounstablebefore returning.
--base unstable \
.github/workflows/update-nix-flake-lock.yml:112
gh pr createdoes not support--jsonor--jq, so the command exits with an unknown-flag error after the branch has been pushed and no pull request is created. Capture its URL, then query the number withgh pr view, which supports these formatting flags.
--json number \
--jq '.number'
.github/workflows/update-terraform-binary-version.yaml:125
gh pr createdoes not support--jsonor--jq, so the command exits with an unknown-flag error after the branch has been pushed and no pull request is created. Capture its URL, then query the number withgh pr view, which supports these formatting flags.
--json number \
--jq '.number'
- Files reviewed: 3/3 changed files
- Comments generated: 5
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Serialize concurrent runs with a workflow-level concurrency group so that scheduled and manually dispatched runs cannot race to create duplicate pull requests. `cancel-in-progress: false` queues the incoming run rather than cancelling the in-progress one, which prevents losing a partially applied update. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
- Pin checkout to `ref: unstable` in the custom-script workflows so
that a manual dispatch from a non-default ref still updates the
correct base and does not include unrelated commits in the PR diff.
- Change `git push --force` to `git push --force-with-lease` to
prevent silently overwriting a concurrent push to the same branch.
- Pass `token: \${{ steps.create-github-app-token.outputs.token }}`
to the `determinatesystems/update-flake-lock` action; the action
defaults to `github.token`, which suppresses downstream workflow
events on the resulting commits and pull requests.
Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
Split `gh pr create` from the number lookup. The `create`
subcommand does not support `--json` or `--jq`; pass those
flags to `gh pr view "${branch}" --json number --jq '.number'`
instead.
Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
Add an inline comment to each flake-checker-action step explaining that at v13 commit de924abd, send-statistics: false maps to NIX_FLAKE_CHECKER_NO_TELEMETRY=false. The environment variable override is required to disable telemetry. See DeterminateSystems/flake-checker-action#134. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
One workflow can still target another branch, and existing automation pull requests remain based on main.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Balanced
Pin `ref: unstable` on the `update-flake-lock` checkout so a manual dispatch from any branch still operates on `unstable`. Retarget existing automation pull requests to `unstable` before exiting the existing-PR path. Without this, any open pull request created by the previous workflow remains on `main` indefinitely. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
Use the default job token for determinate-nix-action instead of the App token. The action writes the supplied token into Nix configuration, exposing write credentials to flake evaluation unnecessarily. Guard each Display Pull Request Link step with an if condition so it skips when no pull request number was produced. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Raw push URLs prevent the lease from using fetched remote-tracking state in two workflows.
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
.github/workflows/update-nix-flake-lock.yml:100
- Passing a raw URL prevents bare
--force-with-leasefrom usingorigin's remote-tracking ref. When this automation branch already exists, the update push can be rejected as stale instead of refreshing the pull request. Configure the authenticated URL asorigin's push URL and push through the named remote so the lease compares against the branch fetched by checkout.
git push --force-with-lease \
"https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git" \
"${branch}"
.github/workflows/update-terraform-binary-version.yaml:110
- Passing a raw URL prevents bare
--force-with-leasefrom usingorigin's remote-tracking ref. When this automation branch already exists, the update push can be rejected as stale instead of refreshing the pull request. Configure the authenticated URL asorigin's push URL and push through the named remote so the lease compares against the branch fetched by checkout.
git push --force-with-lease \
"https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git" \
"${branch}"
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Set the authenticated HTTPS push URL on `origin` before pushing, then push through the named remote. Passing a raw URL to `git push --force-with-lease` bypasses `origin`'s remote-tracking ref, so the lease comparison is incorrect when the automation branch already exists on the remote. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The workflows consistently target unstable, protect concurrent updates, validate changes, and use the intended App identity.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Rename the top-level workflow name from "Update Terraform Binary" to "Update Terraform Binary Version" to match the job and step names already in the file. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
* ci(workflows): harden update workflows Make the `unstable` environment unconditional in all three update workflows so branch protection always applies, even on manual triggers from other refs. - Set `environment.name` to `unstable` unconditionally; the previous conditional expression could bypass the environment when triggered from a non-default ref. - Fix `nixpkgs-keys` to use `nixpkgs` only; `nixpkgs-unstable` is the channel the input follows, not a separate flake input name. - Add `NIX_FLAKE_CHECKER_NO_TELEMETRY: "true"` env var; at the pinned v13 SHA, `send-statistics: false` maps to `=false`, not `=true`, so the env override is required to suppress telemetry. - Add `persist-credentials: false` and `fetch-depth: 0` on checkout; prevents the default `GITHUB_TOKEN` from being stored in git config so that subsequent pushes must use the explicit App token URL. - Push via `https://x-access-token` URL in update scripts so commits use the GitHub App identity and trigger downstream workflows. - Use `--json number --jq '.number'` in `gh pr create`; removes fragile URL stripping with `##*/`. - Change `--base main` to `--base unstable` in PR creation calls. - Replace `git switch --create` with `git switch --force-create` so repeated runs succeed when the branch already exists. - Add `nix flake check` after `nix flake update` in the update-nix-flake-lock script to validate the flake before commit. - Fix Display Pull Request Link step: both expressions now reference `steps.update-nix-flake-lock` instead of `steps.update-flake-lock`. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): add workflow concurrency group Serialize concurrent runs with a workflow-level concurrency group so that scheduled and manually dispatched runs cannot race to create duplicate pull requests. `cancel-in-progress: false` queues the incoming run rather than cancelling the in-progress one, which prevents losing a partially applied update. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): address pr review comments - Pin checkout to `ref: unstable` in the custom-script workflows so that a manual dispatch from a non-default ref still updates the correct base and does not include unrelated commits in the PR diff. - Change `git push --force` to `git push --force-with-lease` to prevent silently overwriting a concurrent push to the same branch. - Pass `token: \${{ steps.create-github-app-token.outputs.token }}` to the `determinatesystems/update-flake-lock` action; the action defaults to `github.token`, which suppresses downstream workflow events on the resulting commits and pull requests. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): fix gh pr create flags Split `gh pr create` from the number lookup. The `create` subcommand does not support `--json` or `--jq`; pass those flags to `gh pr view "${branch}" --json number --jq '.number'` instead. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): document flake-checker-action telemetry bug Add an inline comment to each flake-checker-action step explaining that at v13 commit de924abd, send-statistics: false maps to NIX_FLAKE_CHECKER_NO_TELEMETRY=false. The environment variable override is required to disable telemetry. See DeterminateSystems/flake-checker-action#134. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): pin checkout and retarget prs Pin `ref: unstable` on the `update-flake-lock` checkout so a manual dispatch from any branch still operates on `unstable`. Retarget existing automation pull requests to `unstable` before exiting the existing-PR path. Without this, any open pull request created by the previous workflow remains on `main` indefinitely. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): fix determinate-nix-action token and display step Use the default job token for determinate-nix-action instead of the App token. The action writes the supplied token into Nix configuration, exposing write credentials to flake evaluation unnecessarily. Guard each Display Pull Request Link step with an if condition so it skips when no pull request number was produced. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): push via origin for lease check Set the authenticated HTTPS push URL on `origin` before pushing, then push through the named remote. Passing a raw URL to `git push --force-with-lease` bypasses `origin`'s remote-tracking ref, so the lease comparison is incorrect when the automation branch already exists on the remote. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): rename update terraform binary workflow Rename the top-level workflow name from "Update Terraform Binary" to "Update Terraform Binary Version" to match the job and step names already in the file. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> --------- Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
* ci(workflows): harden update workflows Make the `unstable` environment unconditional in all three update workflows so branch protection always applies, even on manual triggers from other refs. - Set `environment.name` to `unstable` unconditionally; the previous conditional expression could bypass the environment when triggered from a non-default ref. - Fix `nixpkgs-keys` to use `nixpkgs` only; `nixpkgs-unstable` is the channel the input follows, not a separate flake input name. - Add `NIX_FLAKE_CHECKER_NO_TELEMETRY: "true"` env var; at the pinned v13 SHA, `send-statistics: false` maps to `=false`, not `=true`, so the env override is required to suppress telemetry. - Add `persist-credentials: false` and `fetch-depth: 0` on checkout; prevents the default `GITHUB_TOKEN` from being stored in git config so that subsequent pushes must use the explicit App token URL. - Push via `https://x-access-token` URL in update scripts so commits use the GitHub App identity and trigger downstream workflows. - Use `--json number --jq '.number'` in `gh pr create`; removes fragile URL stripping with `##*/`. - Change `--base main` to `--base unstable` in PR creation calls. - Replace `git switch --create` with `git switch --force-create` so repeated runs succeed when the branch already exists. - Add `nix flake check` after `nix flake update` in the update-nix-flake-lock script to validate the flake before commit. - Fix Display Pull Request Link step: both expressions now reference `steps.update-nix-flake-lock` instead of `steps.update-flake-lock`. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): add workflow concurrency group Serialize concurrent runs with a workflow-level concurrency group so that scheduled and manually dispatched runs cannot race to create duplicate pull requests. `cancel-in-progress: false` queues the incoming run rather than cancelling the in-progress one, which prevents losing a partially applied update. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): address pr review comments - Pin checkout to `ref: unstable` in the custom-script workflows so that a manual dispatch from a non-default ref still updates the correct base and does not include unrelated commits in the PR diff. - Change `git push --force` to `git push --force-with-lease` to prevent silently overwriting a concurrent push to the same branch. - Pass `token: \${{ steps.create-github-app-token.outputs.token }}` to the `determinatesystems/update-flake-lock` action; the action defaults to `github.token`, which suppresses downstream workflow events on the resulting commits and pull requests. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): fix gh pr create flags Split `gh pr create` from the number lookup. The `create` subcommand does not support `--json` or `--jq`; pass those flags to `gh pr view "${branch}" --json number --jq '.number'` instead. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): document flake-checker-action telemetry bug Add an inline comment to each flake-checker-action step explaining that at v13 commit de924abd, send-statistics: false maps to NIX_FLAKE_CHECKER_NO_TELEMETRY=false. The environment variable override is required to disable telemetry. See DeterminateSystems/flake-checker-action#134. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): pin checkout and retarget prs Pin `ref: unstable` on the `update-flake-lock` checkout so a manual dispatch from any branch still operates on `unstable`. Retarget existing automation pull requests to `unstable` before exiting the existing-PR path. Without this, any open pull request created by the previous workflow remains on `main` indefinitely. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): fix determinate-nix-action token and display step Use the default job token for determinate-nix-action instead of the App token. The action writes the supplied token into Nix configuration, exposing write credentials to flake evaluation unnecessarily. Guard each Display Pull Request Link step with an if condition so it skips when no pull request number was produced. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): push via origin for lease check Set the authenticated HTTPS push URL on `origin` before pushing, then push through the named remote. Passing a raw URL to `git push --force-with-lease` bypasses `origin`'s remote-tracking ref, so the lease comparison is incorrect when the automation branch already exists on the remote. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): rename update terraform binary workflow Rename the top-level workflow name from "Update Terraform Binary" to "Update Terraform Binary Version" to match the job and step names already in the file. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> --------- Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
* ci(workflows): harden update workflows Make the `unstable` environment unconditional in all three update workflows so branch protection always applies, even on manual triggers from other refs. - Set `environment.name` to `unstable` unconditionally; the previous conditional expression could bypass the environment when triggered from a non-default ref. - Fix `nixpkgs-keys` to use `nixpkgs` only; `nixpkgs-unstable` is the channel the input follows, not a separate flake input name. - Add `NIX_FLAKE_CHECKER_NO_TELEMETRY: "true"` env var; at the pinned v13 SHA, `send-statistics: false` maps to `=false`, not `=true`, so the env override is required to suppress telemetry. - Add `persist-credentials: false` and `fetch-depth: 0` on checkout; prevents the default `GITHUB_TOKEN` from being stored in git config so that subsequent pushes must use the explicit App token URL. - Push via `https://x-access-token` URL in update scripts so commits use the GitHub App identity and trigger downstream workflows. - Use `--json number --jq '.number'` in `gh pr create`; removes fragile URL stripping with `##*/`. - Change `--base main` to `--base unstable` in PR creation calls. - Replace `git switch --create` with `git switch --force-create` so repeated runs succeed when the branch already exists. - Add `nix flake check` after `nix flake update` in the update-nix-flake-lock script to validate the flake before commit. - Fix Display Pull Request Link step: both expressions now reference `steps.update-nix-flake-lock` instead of `steps.update-flake-lock`. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): add workflow concurrency group Serialize concurrent runs with a workflow-level concurrency group so that scheduled and manually dispatched runs cannot race to create duplicate pull requests. `cancel-in-progress: false` queues the incoming run rather than cancelling the in-progress one, which prevents losing a partially applied update. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): address pr review comments - Pin checkout to `ref: unstable` in the custom-script workflows so that a manual dispatch from a non-default ref still updates the correct base and does not include unrelated commits in the PR diff. - Change `git push --force` to `git push --force-with-lease` to prevent silently overwriting a concurrent push to the same branch. - Pass `token: \${{ steps.create-github-app-token.outputs.token }}` to the `determinatesystems/update-flake-lock` action; the action defaults to `github.token`, which suppresses downstream workflow events on the resulting commits and pull requests. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): fix gh pr create flags Split `gh pr create` from the number lookup. The `create` subcommand does not support `--json` or `--jq`; pass those flags to `gh pr view "${branch}" --json number --jq '.number'` instead. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): document flake-checker-action telemetry bug Add an inline comment to each flake-checker-action step explaining that at v13 commit de924abd, send-statistics: false maps to NIX_FLAKE_CHECKER_NO_TELEMETRY=false. The environment variable override is required to disable telemetry. See DeterminateSystems/flake-checker-action#134. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): pin checkout and retarget prs Pin `ref: unstable` on the `update-flake-lock` checkout so a manual dispatch from any branch still operates on `unstable`. Retarget existing automation pull requests to `unstable` before exiting the existing-PR path. Without this, any open pull request created by the previous workflow remains on `main` indefinitely. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): fix determinate-nix-action token and display step Use the default job token for determinate-nix-action instead of the App token. The action writes the supplied token into Nix configuration, exposing write credentials to flake evaluation unnecessarily. Guard each Display Pull Request Link step with an if condition so it skips when no pull request number was produced. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): push via origin for lease check Set the authenticated HTTPS push URL on `origin` before pushing, then push through the named remote. Passing a raw URL to `git push --force-with-lease` bypasses `origin`'s remote-tracking ref, so the lease comparison is incorrect when the automation branch already exists on the remote. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> * ci(workflows): rename update terraform binary workflow Rename the top-level workflow name from "Update Terraform Binary" to "Update Terraform Binary Version" to match the job and step names already in the file. Signed-off-by: Leonard Sheng Sheng Lee <[email protected]> --------- Signed-off-by: Leonard Sheng Sheng Lee <[email protected]>
Summary
Hardens the three update workflows to enforce the
unstableenvironmentunconditionally and fix several correctness issues.
environment.nametounstableunconditionally. The previousconditional expression could bypass environment protection when
triggered from a non-default ref.
nixpkgs-keystonixpkgsonly.nixpkgs-unstableis thechannel the input follows, not a separate flake input name.
NIX_FLAKE_CHECKER_NO_TELEMETRY: "true"as an environmentvariable override. At
flake-checker-actionv13 commitde924abd,send-statistics: falsemaps toNIX_FLAKE_CHECKER_NO_TELEMETRY=false.The environment variable override is required to disable telemetry. See
DeterminateSystems/flake-checker-action#134.
persist-credentials: falseandfetch-depth: 0on checkout.https://x-access-tokenURL so commits use the App identityand trigger downstream workflows.
gh pr createfrom the number lookup. Thecreatesubcommanddoes not support
--jsonor--jq; usegh pr view "${branch}" --json number --jq '.number'to retrieve thenumber after creation.
--base mainto--base unstablein PR creation calls.git switch --createwithgit switch --force-create.nix flake checkafternix flake updatein theupdate-nix-flake-lockscript.steps.update-nix-flake-lockinstead ofsteps.update-flake-lock.concurrency.cancel-in-progress: falseto serialize concurrentscheduled and manual runs and prevent PR creation races.