Skip to content
Latchkey

How to Run a Shell Script From the Repo in GitHub Actions

Check out the repo, ensure the script is executable, then call it from a run step so the logic stays in Git, not the YAML.

Add actions/checkout so the file is present, mark it executable (or invoke it via bash script.sh), then run it. Keeping logic in a script makes it testable and reusable outside CI.

Steps

  • Add actions/checkout@v4 so the script exists on disk.
  • Commit the script with the executable bit, or run it with bash path/to/script.sh.
  • Invoke it from a run: step.

Workflow

.github/workflows/ci.yml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: chmod +x scripts/build.sh
      - run: ./scripts/build.sh

Gotchas

  • Without checkout, the script is not on the runner and you get "No such file or directory".
  • If the executable bit is not committed, call it as bash scripts/build.sh instead of ./scripts/build.sh.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →