# Pin GitHub Actions to Commit SHAs in Your Workflows

Yes. An agent resolves every `uses:` tag in your workflows to the commit it points at today, pins it with the version in a comment, and opens a pull request.

[Run this on Rush](https://cloud.getrush.ai/run/pin-action-versions/github-actions/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads every workflow before it changes one, because a repository rarely pins the same way twice. In a repository shaped like actions/typescript-action, `.github/workflows` holds five workflows: `ci.yml` (TypeScript tests and a job that runs the action itself with `uses: ./`), `check-dist.yml` (rebuilds `dist/` and fails on a diff), `codeql-analysis.yml`, `licensed.yml` and `linter.yml`. Between them they reference `actions/checkout@v6`, `actions/setup-node@v6`, `actions/upload-artifact@v7`, `github/codeql-action/init@v4`, `github/codeql-action/autobuild@v4`, `github/codeql-action/analyze@v4`, `ruby/setup-ruby@v1`, `licensee/setup-licensed@v1.3.2` and `super-linter/super-linter/slim@v8`. Every one is a mutable tag: a major tag like `v6` moves with each release, and even `v1.3.2` can be force-pushed. The agent lists each distinct `owner/repo@ref`, noting that `github/codeql-action/init` and `super-linter/super-linter/slim` are paths inside a repository whose name is the first two segments, and that `uses: ./` is the repository's own action and stays as it is.

For each reference it asks GitHub which commit the tag points at. `gh api repos/actions/checkout/git/ref/tags/v6` returns the tag object; an annotated tag has `type: tag`, so the agent dereferences it with `gh api repos/actions/checkout/git/tags/<sha>` to reach the commit, and a lightweight tag already names the commit. It then finds the exact release that commit carries, so the comment it writes is the full version rather than the floating major: `gh api repos/actions/checkout/git/matching-refs/tags/v6.` lists every `v6.x.y` tag and the agent keeps the one whose commit matches. The line becomes `uses: actions/checkout@<40-character sha> # v6.x.y`, which is the form Dependabot understands and updates. `licensee/setup-licensed@v1.3.2` is already an exact version, but it is pinned to its commit too, since a tag is still a name someone can move.

The repository already has `.github/dependabot.yml` with a `github-actions` ecosystem on a weekly schedule and an `actions-minor` group, so the agent leaves it alone; once lines carry a SHA and a version comment, Dependabot's pull requests replace the SHA and rewrite the comment together. If a repository had no Dependabot config, the agent would add that one entry and say so in the pull request, because a pinned SHA with no updater is how a repository quietly stays on an old action. It makes no other change: the `.node-version` of `24.4.0`, the `node24` runtime in `action.yml`, the `permissions` blocks, the `npm ci` and `npm run bundle` steps and the `FILTER_REGEX_EXCLUDE: dist/**/*` setting in the linter job are not its business.

Before opening the pull request it checks its own work. `actionlint`, configured by the repository's `actionlint.yml`, parses every workflow and confirms each `uses:` is still a valid reference. The agent also runs `zizmor .github/workflows`, whose `unpinned-uses` audit flags any `uses:` that still names a tag, so an action it missed shows up as a finding rather than a surprise. It pastes both outputs into the pull request body under a table with one row per action: the file and line, the ref it had, the commit it now has and the version in the comment, each with the `gh api` call a reviewer can repeat.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Pin every third-party GitHub Action in this repository to a full commit SHA and open a pull request. Read every file under .github/workflows and .github/dependabot.yml first. For each distinct uses: reference to another repository (treat owner/repo/path@ref as the repository owner/repo), resolve the ref to its commit with gh api repos/<owner>/<repo>/git/ref/tags/<ref>, dereferencing an annotated tag through git/tags/<sha>, and find the exact release tag on that commit with git/matching-refs/tags/. Rewrite the line as owner/repo[/path]@<sha> # <exact version>. Leave uses: ./ and any local action alone, and change nothing else in the workflows. If .github/dependabot.yml has no github-actions ecosystem entry, add one on a weekly schedule; if it has one, leave it as it is. Install actionlint and zizmor, run actionlint and zizmor .github/workflows, and fix anything they report about your change. Open a pull request whose body has a table with one row per action (file and line, old ref, new sha, version), the gh api command for each resolution, and the actionlint and zizmor output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request touches only the workflow files, and in them only the `uses:` lines: in a repository like actions/typescript-action that is five files, each `owner/repo@vN` now `owner/repo@<sha> # vN.x.y`, and `uses: ./` untouched. The body carries the table of what each reference resolved to, the `gh api` commands behind it, the `actionlint` output and the `zizmor` output, so a reviewer can check any row without trusting the agent's resolution.

The repository's own workflows then run on the pull request with the pinned actions: `ci.yml`, `check-dist.yml`, `linter.yml`, `codeql-analysis.yml` and `licensed.yml` all trigger on `pull_request` to `main`, and a SHA that did not resolve to a runnable action would fail at checkout of that step. Green checks mean every pin is a real commit of the right repository.

A reviewer spot-checks two or three rows with the pasted commands, confirms the version in each comment matches the commit (the comment is documentation and Dependabot's anchor, not what runs), and checks that `dependabot.yml` still covers `github-actions` so the pins keep moving. A pin to a commit that carries no release tag is worth a question: the agent should have written the nearest tag or explained why there is none.

## Run it on every repository in your organization

The same request runs once per repository: a script on your server lists what the Rush GitHub App can reach with `GET /o/{org}/github`, and for each repository whose workflows still contain `@v` references sends one `POST /o/{org}/sessions` with this prompt and that repository in `resources`. Give each request a `request_id` that is a UUID v5 of the repository name and the date, so a retry returns the run it already started instead of opening a second pull request.

A key runs at most its `max_concurrent` sessions at once (4 by default), yet the script can send every repository in one pass: starts past the limit answer `202` with `status: "queued"` and begin when a slot frees, and each `run.completed` webhook carries `data.session_url` for that repository's pull request. After the first pass, Dependabot keeps the pins fresh and the script finds nothing left to send.

## Why run it on Rush?

Pinning by hand means a dozen `gh api` calls per repository, copying forty-character strings into YAML, and getting the version comment right so Dependabot can take over. Done on a laptop it is tedious once and skipped the second time. On Rush the agent does the resolution in its own sandbox, every `gh api` call and its answer stays in the transcript, and the pull request carries the table that proves each line.

The checks are the ones you already have. The repository's workflows run on the pull request with the pinned actions, `actionlint` and `zizmor` confirm nothing is left unpinned, and nothing merges until a person reads the table. With the GitHub App installed on an organization, the same prompt reaches every repository without anyone opening each one.

## Frequently asked questions

### Why a commit SHA when the tag already names a version?

A tag is a mutable name: a major tag like `v6` is moved to each new release on purpose, and any tag can be force-pushed by whoever controls the repository. A commit SHA names exactly one tree, so what ran yesterday is what runs today. The version comment keeps the line readable and lets Dependabot update it.

### Will Dependabot still update the actions after pinning?

Yes, when `.github/dependabot.yml` has a `github-actions` entry, as actions/typescript-action does. Dependabot reads the version comment after the SHA, opens a pull request with the new commit and rewrites the comment. The agent adds that entry only when it is missing.

### What about actions that live in a subdirectory, like codeql-action/init?

The repository is the first two path segments and the rest is the action's path inside it, so `github/codeql-action/init@v4` resolves against `github/codeql-action` and becomes `github/codeql-action/init@<sha> # v4.x.y`. The same holds for `super-linter/super-linter/slim`.

### Does it touch my local action or reusable workflows?

No. `uses: ./` and `uses: ./.github/actions/<name>` run code from the same checkout and have no tag to pin. A reusable workflow in another repository, `owner/repo/.github/workflows/x.yml@ref`, is pinned the same way as an action.

### What does it do when a tag points at a commit with no release tag?

It writes the SHA and, in the comment, the tag it resolved from, and says so in the table. That happens when a maintainer moved a major tag to an unreleased commit; a reviewer may prefer to pin the last tagged release instead, and the row makes the choice visible.

## More GitHub Actions jobs

- [Review GitHub Actions Workflow Changes](https://getrush.ai/run/review-workflow-changes/github-actions/)
- [Upgrade Pinned GitHub Actions to the Latest Releases](https://getrush.ai/run/update-github-actions/github-actions/)
- [Write Tests for a Custom GitHub Action](https://getrush.ai/run/write-action-tests/github-actions/)

## More jobs like this: Hand off a long task

- [Protect a DynamoDB Global Table and Its KMS Keys from Deletion in an AWS CDK App](https://getrush.ai/run/protect-stateful-resources/aws-cdk/)
- [Protect Databases and Secrets from Accidental Deletion in a Pulumi Program](https://getrush.ai/run/protect-stateful-resources/pulumi/)
- [Publish a Helm Chart to an OCI Registry](https://getrush.ai/run/publish-chart-to-oci/helm/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
