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.
2. Select the Official Checkout Action
Choose the Checkout Action maintained by GitHub. Look for the verified badge next to the publisher name.
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.
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 Name | Action |
---|---|
Checkout Repository | uses: actions/checkout@v4 |
Welcome message | run: echo "My first GitHub Actions Job" |
List files | run: ls |
Read file | run: 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.
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.
Links and References
Watch Video
Watch video content