Skip to content

fix(ci): nix workflow hardening#286

Merged
cachebag merged 1 commit intomasterfrom
ci
Mar 17, 2026
Merged

fix(ci): nix workflow hardening#286
cachebag merged 1 commit intomasterfrom
ci

Conversation

@cachebag
Copy link
Owner

@cachebag cachebag commented Mar 17, 2026

Following changes were made to try and fix this issue with our nix updating workflow

Trigger: pull_request_target instead of pull_request + push

  • Runs in the context of the base repo, so GITHUB_TOKEN has write access to the PR branch even for fork PRs
  • Only fires when Cargo.lock, package.nix, or the workflow itself changes; no more wasted runs
  • Removed the push trigger entirely since auto-fixing hashes only makes sense on PRs

Commit via GitHub API instead of git push

  • Uses gh api repos/.../contents/package.nix --method PUT to commit the updated file directly through the API
  • GitHub treats this as a normal commit on the branch; no rebase, no force-push, no "base branch was modified" errors
  • No git commit --amend, no git rebase, no git push --force

Fork PR handling

  • For same-repo PRs: commits the fix directly via the API
  • For fork PRs: the bot can't push to forks, so instead it leaves a PR comment with the correct hash value for the contributor to update themselves

Deprecated action replaced

  • actions-rs/toolchain@v1 swapped for dtolnay/rust-toolchain@stable

Additionally, we now conditionally run our CI based on what folders/files were edited.

I had Opus 4.6 via Cursor complete this entire change for me.

@cachebag cachebag self-assigned this Mar 17, 2026
@cachebag cachebag added bug Something isn't working config Changes to NixOS, GHA, dev config, etc. labels Mar 17, 2026
@cachebag cachebag merged commit af03aff into master Mar 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working config Changes to NixOS, GHA, dev config, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant