{{ message }}
Repository navigation
Add sentinel comment to managed workflow files - #61
Merged
Merged
Conversation
Prepend "# This workflow is managed by gh actions-lock." to the top of workflow files when they are rewritten during pin commit. The comment is idempotent — skipped if already present — and separated from the YAML body by a blank line.
Previously rewriteWorkflow bailed early when there were no rewrites, so already-pinned workflows never got the sentinel comment. Now every workflow in the plan gets EnsureSentinel applied, with a bytes.Equal check to avoid unnecessary disk writes.
There was a problem hiding this comment.
⚠️ Not ready to approve
Sentinel insertion logic and commit-phase application don’t fully match the stated “only when uses: lines actually change” behavior and can fail to prepend the sentinel when the text appears later in the file.
Pull request overview
Adds a single-line sentinel comment to the top of workflow files that gh actions-lock rewrites, so it’s obvious the workflow is lockfile-managed.
Changes:
- Introduce
EnsureSentinel(andSentinelComment) to prepend# This workflow is managed by gh actions-lock.to workflow content. - Add unit tests covering sentinel insertion behavior.
- Call
EnsureSentinelduring the commit-phase workflow rewrite.
File summaries
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 2
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bytes.Contains would miss prepending if the sentinel text appeared elsewhere in the file (e.g. in a run: block or unrelated comment). Switch to bytes.HasPrefix so we only skip when it is already at the top.
Every workflow that goes through planWorkflow now gets a WorkflowPlan entry even when there are no rewrites (already pinned, partial failure, impostor blocked, etc). The rewriteWorkflow function applies EnsureSentinel to all of them, with bytes.Equal preventing unnecessary disk writes when nothing changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When
gh actions-lockrewrites a workflow file to pin action refs, there's novisible indicator that the file is under lockfile management. This makes it easy
for someone editing a workflow to not realize their
uses:lines are locked andwill be overwritten on the next pin run.
This adds a sentinel comment --
# This workflow is managed by gh actions-lock.-- prepended to workflow files during the commit phase. The comment is:
doesn't stack duplicate comments.
body by a blank line (or merged with existing leading comments).
rewriteWorkflowactually changesuses:lines -- workflows with no rewrites are untouched.Inspired by this Slack thread
discussing how to signal lockfile management at a glance.