Skip to content

MegaLinter auto-fix push fails whenever it reformats a workflow file, and only once the gate is green #703

Description

@devantler

🤖 Generated by the Agentic Engineer

Evidence

validate-go-project.yaml's lint job runs MegaLinter with APPLY_FIXES: all and then pushes the
result with git-auto-commit-action, using a GitHub App token minted with permission-contents: write only. When MegaLinter's auto-fix touches a workflow file, the push is refused and the job
fails:

! [remote rejected] HEAD -> claude/lint-gate-green-2775
  (refusing to allow a GitHub App to create or update workflow
   `.github/workflows/ci.yaml` without `workflows` permission)

Measured on devantler-tech/platform, run 29857799818, job 88726527021: the lint step itself
succeeded
— every linter green or non-blocking — and the job still reported failure, on step 9.

Why it has stayed hidden

The push step has no always(), so it only runs when linting passed. On any repository whose
MegaLinter baseline is red, the step is skipped and the defect is invisible. It surfaces the moment
a repository first gets its lint gate green — which is exactly when someone is least expecting a
failure, and when the failure text is furthest from the cause: the summary reads "Lint" and the log
shows a clean linter table.

Who it affects

Every repository consuming this workflow whose YAML formatting differs from prettier's defaults in
.github/**, which is easy to reach — a long needs: [...] array or single-quoted strings are
enough.

Expected behaviour

Either the auto-fix push succeeds for workflow files, or MegaLinter never rewrites them.

Options

  1. Add permission-workflows: write to the App token in the lint job. Smallest change, but it
    widens a token that today can only touch file contents, on a job that runs against pull-request
    branches — worth weighing rather than assuming.
  2. Keep the token as-is and stop the fixers touching .github/**, so the push can never contain a
    workflow change. Loses prettier's formatting check on workflow files, which actionlint and
    yamllint do not replace.
  3. Let the step fail soft with a clear message telling the author to run the formatter locally,
    which is what the sibling fork-PR step already does.

I have no strong preference between 2 and 3; 1 deserves a deliberate decision because it is a
permission widening on a token reachable from pull-request branches.

Workaround in place

devantler-tech/platform formats its own .github/** YAML so there is nothing to push back. That
works per-repository but does not stop the next repo hitting it.

Acceptance criteria

  • A repository with a green MegaLinter baseline and unformatted workflow YAML gets a green
    🧹 Lint - mega-linter job.
  • If the chosen fix is a permission widening, the reasoning is recorded next to it.

Rough size: small.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status
    📥 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions