When a workflow runs, the runner machine is empty. It does not have your GitHub repository files by default.
If you want to access any file from your repository inside the runner, you must use:
uses: actions/checkout@v4
This action copies your entire GitHub repository into the runner’s working directory.
Without checkout action, commands like cat, ls, pwd will not show your repo files.
Example workflow:
name: Show File Content
on:
workflow_dispatch:
jobs:
show:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: List files
run: ls -ltr
- name: Display file content
run: cat sample.txt
Explanation:
- Checkout action brings your GitHub repository into runner
- ls -ltr shows files from your repo
- cat sample.txt prints the content of the file you already have in GitHub
Replace sample.txt with the actual file name in your repository.
The repo contains your file. The checkout action pulls that file into the runner. Then you can run Linux commands to view or process it.
Example:
cat README.md
cat myscript.sh
cat folder/data.txt