Sub topic 1
What a uses: reference points to
Every uses: line in a workflow names code that GitHub runs on your behalf. This chapter shows how to read that line, what each part resolves to, and which parts you control.
Prerequisites
This chapter assumes you have:
- Basic GitHub Actions syntax: jobs, steps, and the
uses:key. - Git basics: commits, tags, and branches.
- Familiarity with version tags such as
v4.
The anatomy of a reference
A uses: value has up to three parts: the location of the code, an optional path inside it, and a ref after the @.
name: reference-forms
on: push
jobs:
demo:
runs-on: ubuntu-latest
steps:
# owner/repo@ref: action defined at the repository root
- uses: actions/checkout@v4
# owner/repo/path@ref: action defined in a subdirectory
- uses: github/codeql-action/init@v3
# ./path: action stored in your own repository
- uses: ./.github/actions/setup-tools
# docker://image:tag: container image from a registry
- uses: docker://alpine:3.20
with:
args: echo helloThe @ref part tells GitHub which version of the repository to fetch. The same ref syntax also applies to reusable workflows, which you call at the job level instead of the step level:
name: call-reusable
on: push
jobs:
call:
uses: my-org/shared-workflows/.github/workflows/build.yml@v2What a ref can be
The ref after @ can be one of three things.
| Ref type | Example | What it resolves to | Can it change? |
|---|---|---|---|
| Branch | `@main` | The newest commit on that branch | Yes, on every push |
| Tag | `@v4` | The commit the tag points to | Yes, if the tag is moved or deleted and recreated |
| Full commit SHA | `@11bd71901bbe5b1630ceea73d27597364c9af683` | Exactly one commit | No |
A SHA is a hash of the commit's content and history. Changing the code produces a different SHA, so a SHA cannot be quietly repointed. A branch or tag is only a name, and the repository owner can reassign the name.
How the runner resolves a reference
When a job starts, the runner reads each uses: value and resolves it to a commit. It then downloads that commit's contents and runs the action definition it finds there. Nothing in your repository records which commit a tag pointed to at the time. If you re-run the workflow tomorrow, the runner resolves the tag again.
Local actions (./path) are different. They are read from the checked-out files of the workflow run, so they need an earlier actions/checkout step in the same job. Their version is whatever commit your workflow runs on, which your own review process already covers.
Docker references are also a different case. The docker://alpine:3.20 form names an image tag in a registry, and registry tags can be repointed as well.
What you control
Your workflow file decides which ref is written. It does not decide what that ref points to. For third-party actions, the maintainer or anyone with write access to their repository decides that.
The ref also determines the permissions context. The action runs inside your job, so it can read the job's GITHUB_TOKEN and any secrets you pass to it. Resolving a ref to unexpected code therefore exposes those credentials.
Exercise
A workflow contains uses: acme/deploy-action/staging@v2. Name the repository, the path inside it, and the ref. Then say whether the ref identifies a single fixed commit.
Show answer
The repository is acme/deploy-action, the path inside it is staging, and the ref is v2. A tag such as v2 is not guaranteed to identify a single fixed commit, because the maintainer can move it to a different commit. Only a full-length commit SHA is fixed.