Skip to content

fix(md-autofix): fetch PR files before running script - #732

Merged
hilram7 merged 2 commits into
devfrom
fix/md-autofix-fetch-pr-files
Apr 9, 2026
Merged

fix(md-autofix): fetch PR files before running script#732
hilram7 merged 2 commits into
devfrom
fix/md-autofix-fetch-pr-files

Conversation

@hilram7

@hilram7hilram7 commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes a bug where the md-extension-autofix workflow ran successfully but
processed 0 files — producing no renames, no frontmatter injection, and no
PR comment output.

Root cause

As a security measure, the workflow checks out the base branch (dev)
rather than the PR head. This means new files added in a PR don't exist on
disk when the script runs. The script's [ -f "$file" ] check correctly
skips files that don't exist (treating them as deleted), so all new files
were silently ignored.

Fix

Adds a step between "Get changed files" and "Run md-extension-autofix" that
fetches only the specific changed files from the PR head commit:

- name: Fetch changed files from PR head if: steps.changed-files.outputs.count > 0 run: |  git fetch origin ${{ github.event.pull_request.head.sha }}  while IFS= read -r file; do  git checkout FETCH_HEAD -- "$file" 2>/dev/null || true done < /tmp/changed-files.txt

The script itself still runs from the trusted base checkout. Only file content is fetched from the PR head via git show, and is not executed.

CodeQL: Actions/untrusted-checkout/medium flagged this step and was dismissed. PRs are restricted to Netwrix org members with SSO; the untrusted-contributor attack vector does not apply.

Testing

@hilram7
hilram7 marked this pull request as ready for review April 9, 2026 20:42
@hilram7
hilram7 merged commit 28e13af into devApr 9, 2026
7 checks passed
@hilram7
hilram7 deleted the fix/md-autofix-fetch-pr-files branch April 9, 2026 21:18
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@hilram7