# Steps: uses and run — GitHub Actions

Source: https://www.skillbyai.com/en/github-actions/j-steps

> Actions and shell commands.

## Building blocks of a job

Steps run sequentially on the same runner and share its filesystem. A `uses` step runs an action (from the Marketplace, another repository, or a local path) configured with `with:` inputs; a `run` step executes shell commands (bash on Linux and macOS by default, with `set -e` behaviour so a failing command fails the step). Steps can set `env`, `if` conditions, `id` for referencing outputs, `continue-on-error`, `timeout-minutes` and `working-directory`. Use multi-line `run: |` blocks for scripts.

## Compose pipelines

Steps run in order inside a job; needs orders jobs; outputs and artifacts move data between them.

![Three ideas: steps, job dependencies, outputs and artifacts.](assets/figures/github-actions/section-3-map.svg) — Figure 3.1 — Steps, needs and data flow.

## Common step patterns

Not linted or run here; check the GitHub Actions documentation for current syntax.

```yaml
steps:
  - uses: actions/checkout@v4            # get the code
  - uses: actions/setup-python@v5
    with:
      python-version: "3.12"
  - name: Install and test
    working-directory: api
    env:
      PYTHONDONTWRITEBYTECODE: "1"
    run: |
      pip install -r requirements.txt
      pytest -q
```

## Use run: | for anything with colons

Block scalars avoid YAML parsing surprises; an unquoted "echo New issue: x" line broke this course's own example until it was rewritten.

**Quiz:** What is the difference between uses and run?

- [x] uses runs a packaged action; run executes shell commands
- [ ] They are identical
- [ ] run only works on Windows
- [ ] uses only installs Node.js

*Answer:* uses runs a packaged action; run executes shell commands. Actions versus scripts.
