til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Use checkout

This is a simple action that allows you to checkout your repository. It is a very common action and is used in many workflows. The action is maintained by GitHub and is available at actions/checkout.

To use the action, you can add the following step to your workflow file:


steps:
  - name: Checkout
    uses: actions/checkout@v4

You can use the v4 tag to get the latest version of the action. If you want to use a specific version, you can specify the version number like this:

steps:
  - name: Checkout
    uses: actions/checkout@v4.1.1

The recommendation these days however seem to be to pin the version of the action, so you may need to update the SHA checksums in your workflow file. The SHA checksums are used to ensure that the action is not tampered with and that the action is the same version that you expect.

    steps:
    - name: Checkout
      uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

In order to resolve the SHA checksums do see my TIL on that How do I resolve the SHA checksum.

The action has a lot of options that you can use to customize the behavior. You can find more information about the action in the GitHub Marketplace.

Fetch Depth

The fetch-depth option allows you to specify how many commits to fetch. By default, the action fetches the latest commit only. If you want to fetch all commits, you can set the fetch-depth to 0.

This is used by the action for goreleaser, which is used to build precompiled binaries. Do see my TIL on that Build Precompiled Binaries.

    steps:
      - name: Checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          fetch-depth: 0

Resources and References