Skip to content

Latest commit

 

History

History
66 lines (43 loc) · 1.27 KB

File metadata and controls

66 lines (43 loc) · 1.27 KB

What is checkout action

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.


How to display your file content using checkout action

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:

  1. Checkout action brings your GitHub repository into runner
  2. ls -ltr shows files from your repo
  3. 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.


Example explanation

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