GitHub Actions

GitHub Actions Core Concepts

Configure Checkout Action

In this lesson, you’ll learn how to add the actions/checkout step to your GitHub Actions workflow, ensuring your repository code is available for subsequent steps.

Prerequisites

  • A GitHub repository
  • Basic familiarity with GitHub Actions and YAML syntax

1. Browse the GitHub Marketplace

Visit the GitHub Marketplace and search for “checkout” to filter relevant actions.

The image shows the GitHub Marketplace interface with a search for "checkout" actions, displaying various options for automating development workflows. The left sidebar lists categories like API management and code quality.

2. Select the Official Checkout Action

Choose the Checkout Action maintained by GitHub. Look for the verified badge next to the publisher name.

The image shows a GitHub Marketplace page for the "Checkout" GitHub Action, detailing its version, usage, and features. It includes information about the action's functionality, contributors, and updates.

3. Review the Checkout Action Documentation

The actions/checkout@v4 README contains usage examples and configurable options. Review it for advanced scenarios like submodule fetching or shallow clones.

The image shows a GitHub documentation page for the "actions/checkout" action, highlighting usage instructions and configuration options for setting up a repository checkout in a workflow.

4. Update Your Workflow File

Add the checkout step at the top of your job’s steps list so that all subsequent commands have access to your repository files.

name: My First Workflow
on: push

jobs:
  first_job:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Welcome message
        run: echo "My first GitHub Actions Job"

      - name: List files
        run: ls

      - name: Read file
        run: cat README.md

Warning

If you omit actions/checkout, subsequent steps won’t have access to your code, leading to errors such as file not found when running commands like ls or cat.

For clarity, here’s an overview of each step in the workflow:

Step NameAction
Checkout Repositoryuses: actions/checkout@v4
Welcome messagerun: echo "My first GitHub Actions Job"
List filesrun: ls
Read filerun: cat README.md

5. Commit and Trigger the Workflow

Commit your changes and push to GitHub. Navigate to the Actions tab to watch your workflow run live.

The image shows a GitHub Actions workflow interface with a job named "first job" that has successfully completed several steps, including setting up the job, checking out the repository, and completing the job.

6. Inspect the Logs

In the job logs, you’ll see the checkout action pulling down your repository. To view hidden files (e.g., the .github directory), use:

Note

Run ls -a to display all files, including those starting with a dot.

ls -a

7. Review Workflow History

Return to the main Actions page to see past runs, both successful and failed, and download logs or enable timestamps.

The image shows a GitHub Actions page with a workflow named "My First Workflow." It displays two workflow runs, one successful and one failed.

Watch Video

Watch video content

Previous
What are Actions