GitHub Actions - Clone a repository using actions/checkout

by
Jeremy Canfield |
Updated: June 01 2025
| GitHub Actions articles
There are a couple different ways to clone a repository.
- clone a repository using the git clone command
- clone/checkout a repository in a GitHub Actions workflow using actions/checkout (this article)
In this example, the repository that the GitHub Action workflow is running in will be cloned / checked out to $GITHUB_WORKSPACE on the runner virtual machine (VM).
name: my-workflow
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
workflow_dispatch:
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: clone/checkout this repository to $GITHUB_WORKSPACE
uses: actions/checkout@v4
with repository can be used to clone/checkout a specific repository.
name: my-workflow
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
workflow_dispatch:
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: clone/checkout this repository to $GITHUB_WORKSPACE
uses: actions/checkout@v4
with:
repository: 'acme/my-repo'
with path can be used to clone/checkout the repository to a specific directory below $GITHUB_WORKSPACE on the runner VM.
name: my-workflow
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
workflow_dispatch:
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: clone/checkout this repository to $GITHUB_WORKSPACE
uses: actions/checkout@v4
with:
path: 'foo'
Did you find this article helpful?
If so, consider buying me a coffee over at