Skip to content

CI: Pin third-party GitHub Actions to commit SHAs#5972

Open
rogerbarreto wants to merge 1 commit into
microsoft:mainfrom
rogerbarreto:issues/lock-workflow-versioning
Open

CI: Pin third-party GitHub Actions to commit SHAs#5972
rogerbarreto wants to merge 1 commit into
microsoft:mainfrom
rogerbarreto:issues/lock-workflow-versioning

Conversation

@rogerbarreto
Copy link
Copy Markdown
Member

Summary

Pins every third-party GitHub Action referenced in our workflows and composite actions to an immutable 40-character commit SHA, with a # vX comment so Dependabot can still raise version-bump PRs.

Why pin to SHA: a floating tag like actions/checkout@v6 resolves whatever commit the tag points to at run time. If an action repo is compromised, or a maintainer force-pushes a tag, our workflows execute the new code. A SHA pin freezes the bits and is one of the StepSecurity / OpenSSF Scorecard hardening recommendations.

Changes

1. SHA pins (186 occurrences across 27 files)

Every uses: <owner>/<repo>@<tag> rewritten as:

uses: <owner>/<repo>@<40-char-sha> # <tag>

Files touched:

  • 25 workflow files under .github/workflows/
  • 2 composite actions under .github/actions/ (python-setup, sample-validation-setup)

The remaining 2 composite actions (setup-local-mcp-server, azure-functions-integration-setup) have no third-party uses: so they were not modified.

2. Dependabot scope widened

.github/dependabot.yml previously used directory: "/" for the github-actions ecosystem. Per the Dependabot docs and dependabot-core source, that only scans .github/workflows/*.{yml,yaml} plus a repo-root action.yml. Composite actions under .github/actions/*/action.yml were silently uncovered.

Switched to the plural directories key with a glob (the singular directory key does not support globs):

directories:
  - "/"
  - "/.github/actions/*"

Now both python-setup and sample-validation-setup are in scope, and any future composite action added under .github/actions/<name>/ is picked up automatically.

Verification

  • python -c "import yaml; yaml.safe_load(...)" parses all 30 modified yaml files cleanly.
  • Every third-party uses: line now ends in a [0-9a-f]{40} SHA followed by # vX. Verified with a regex sweep.
  • Local ./ references (reusable workflows, internal composite actions) left untouched, as intended.

Follow-ups (out of scope)

  • Could add groups: for the github-actions ecosystem to batch all Dependabot action bumps into one weekly PR instead of one per action.
  • The github-actions block has no labels: while nuget / pip / uv do. Could add ["ci", "dependencies"] for filter consistency.

Happy to address either in a follow-up if requested.

Replaces every floating tag in our workflow and composite action files
with an immutable 40-character commit SHA, keeping the original `# vX`
comment so Dependabot can still propose version bumps. 186 occurrences
across 25 workflows and 2 composite actions.

Also widens the github-actions Dependabot entry to use the plural
`directories` key with `/.github/actions/*` so composite actions under
`.github/actions/<name>/action.yml` are kept up to date. Previously
Dependabot only scanned `.github/workflows` and the repo-root
`action.yml`, leaving our `python-setup` and `sample-validation-setup`
composite actions unmaintained.
Copilot AI review requested due to automatic review settings May 20, 2026 11:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens CI supply-chain security by pinning all third-party GitHub Actions references to immutable commit SHAs (while retaining the original tag in a trailing comment for update visibility), and expands Dependabot scanning so composite actions under .github/actions/* are included.

Changes:

  • Pin third-party action uses: references to 40-char commit SHAs across workflows and composite actions.
  • Widen Dependabot’s github-actions scan scope to include .github/actions/* composite actions.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/stale-issue-pr-ping.yml Pin actions/checkout and actions/setup-python to SHAs.
.github/workflows/python-tests.yml Pin actions/checkout and pmeier/pytest-results-action to SHAs.
.github/workflows/python-test-coverage.yml Pin actions/checkout and actions/upload-artifact to SHAs.
.github/workflows/python-test-coverage-report.yml Pin actions/checkout, actions/download-artifact, and coverage comment action to SHAs.
.github/workflows/python-sample-validation.yml Pin actions/checkout, artifact upload/download, and cache actions to SHAs.
.github/workflows/python-release.yml Pin actions/checkout and softprops/action-gh-release to SHAs.
.github/workflows/python-merge-tests.yml Pin actions/checkout, dorny/paths-filter, azure/login, artifact/cache, and reporting actions to SHAs.
.github/workflows/python-lab-tests.yml Pin actions/checkout, dorny/paths-filter, and test reporting action to SHAs.
.github/workflows/python-integration-tests.yml Pin actions/checkout, azure/login, artifact/cache, and actions/github-script to SHAs.
.github/workflows/python-docs.yml Pin actions/checkout and astral-sh/setup-uv to SHAs.
.github/workflows/python-dev-dependency-upgrade.yml Pin actions/checkout to a SHA.
.github/workflows/python-dependency-range-validation.yml Pin actions/checkout, artifact upload, and actions/github-script to SHAs.
.github/workflows/python-code-quality.yml Pin actions/checkout, actions/cache, and j178/prek-action to SHAs.
.github/workflows/merge-gatekeeper.yml Pin actions/github-script to a SHA.
.github/workflows/markdown-link-check.yml Pin actions/checkout and umbrelladocs/action-linkspector to SHAs.
.github/workflows/label-title-prefix.yml Pin actions/github-script to a SHA.
.github/workflows/label-pr.yml Pin actions/labeler to a SHA.
.github/workflows/label-issues.yml Pin actions/github-script to a SHA.
.github/workflows/issue-triage.yml Pin actions/checkout, actions/github-script, actions/setup-python, astral-sh/setup-uv, and azure/login to SHAs.
.github/workflows/dotnet-verify-samples.yml Pin actions/checkout, actions/setup-dotnet, azure/login, and artifact upload to SHAs.
.github/workflows/dotnet-integration-tests.yml Pin actions/checkout, actions/setup-dotnet, and azure/login to SHAs.
.github/workflows/dotnet-format.yml Pin actions/checkout and jitterbit/get-changed-files to SHAs.
.github/workflows/dotnet-build-and-test.yml Pin actions/checkout, actions/setup-dotnet, azure/login, reporting, artifact/cache, and actions/github-script actions to SHAs.
.github/workflows/devflow-pr-review.yml Pin actions/github-script, actions/checkout, actions/setup-python, and astral-sh/setup-uv to SHAs.
.github/workflows/codeql-analysis.yml Pin actions/checkout and github/codeql-action/* to SHAs.
.github/dependabot.yml Expand github-actions updates to scan both workflows and composite actions via directories.
.github/actions/sample-validation-setup/action.yml Pin actions/setup-node and azure/login to SHAs.
.github/actions/python-setup/action.yml Pin astral-sh/setup-uv to a SHA.

Comment thread .github/workflows/dotnet-build-and-test.yml
@rogerbarreto rogerbarreto changed the title ci: pin third-party GitHub Actions to commit SHAs CI: Pin third-party GitHub Actions to commit SHAs May 20, 2026
@rogerbarreto rogerbarreto self-assigned this May 20, 2026
Sign up for free to 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.

4 participants