Skip to content

Support auto-correcting version comments when they don’t match the action SHA #1434

@ManuelLerchnerQC

Description

@ManuelLerchnerQC

Feature Overview

Add optional --fix and --check when using --verify, so pinact can auto-correct version comments that don’t match the actual commit SHA in the uses line.
The safe approach is to adapt the comment to the hash (not the other way around), so existing pipelines keep using the same ref and don’t break.

Why is the feature needed?

In practice, users (or sometimes even Dependabot) update the hash but forget to update the version comment, so the comment and the ref disagree. Manually fixing many workflow files is tedious and error-prone. The feature is needed so pinact can:

  • --verify --fix: Correct the version comment to match the actual SHA and write the file.
  • --verify --check: Show what would be corrected (e.g. in CI) without writing, and exit non-zero when corrections would be needed.

Existing behaviour stays the same: pinact run --verify (without --fix/--check) still only reports mismatches and does not modify files.

Example Code

Current behaviour (unchanged): mismatch is reported, no file change.

$ pinact run --verify .github/workflows/ci.yaml
ERRO[...] verify the version annotation: action_version must be equal to commit_hash_of_version_annotation ...

New behaviour with --check (preview, no write):

$ pinact run --verify --check .github/workflows/ci.yaml
WARN[...] version annotation mismatch detected, correcting comment ... correct_version=v2.7.0
# Exit non-zero; file unchanged but would be corrected

New behaviour with --fix (correct comment and write):

$ pinact run --verify --fix .github/workflows/ci.yaml
WARN[...] version annotation mismatch detected, correcting comment ... correct_version=v2.7.0
# File is updated: comment changed from # v3.5.1 to # v2.7.0 to match the SHA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions