🎓 A1Learner
🔍
0 of 50 lessons completed

GitHub Actions: actions/checkout

actions/checkout is an action that downloads a copy of the repository onto the runner. Almost every workflow starts with it.

The first step

This is the usual first step of a job.

- uses: actions/checkout@v7

See what it downloaded

List the files after checkout runs.

- uses: actions/checkout@v7
- run: ls

Checkout before setup

Checkout comes first in most workflows. Later steps then work on the code.

steps:
  - uses: actions/checkout@v7
  - uses: actions/setup-node@v7
    with:
      node-version: '24'

Example

name: Checkout demo

on: push

jobs:
  checkout-demo:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - run: ls
      - uses: actions/setup-node@v7
        with:
          node-version: '24'
      - run: npm test

Key points

  • actions/checkout: the action that downloads the repo onto the runner.
  • Use it as the first step of a job.
  • Without it, the runner has no code to test or build.
  • It checks out the same commit that started the workflow.
  • The download includes every file in the repo.
  • The action is free and maintained by GitHub.
  • Checkout gives the runner the code. Every later step works on that copy.

In this example, the workflow runs on every push. The first step checks out the repo. The second step lists the files, so the run log shows the download worked. The third step installs Node 24. The last step runs the tests, which pass.

Note

The runner starts empty. Nothing from the repo is there until checkout runs.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

Why do most workflows start with actions/checkout?