Bootstrap FreeKB - GitHub Actions - Clone a repository using actions/checkout
GitHub Actions - Clone a repository using actions/checkout

Updated:   |  GitHub Actions articles

There are a couple different ways to clone a repository.

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 Buy Me A Coffee



Comments


Add a Comment


Please enter 3df8ff in the box below so that we can be sure you are a human.