Skip to content

Home / Blog / Runners and limits

How do I fix "every step must define a `uses` or `run` key" in GitHub Actions?

"every step must define a `uses` or `run` key" means a step has neither an action nor a command. The stray dash and the settings-only step, with fixes.

“every step must define a `uses` or `run` key” means one item in a job’s steps list has neither a run command nor a uses action, so there is nothing for it to do. The 2 usual causes are a stray dash that splits one step into two, and a step that holds only a name or another setting. Find the item without either key and merge it into its neighbour.

In short
  • One item in a job's steps list has neither run nor uses, so GitHub refuses the whole workflow file.
  • The cause in the reports is a dash in front of both name and uses, which makes two steps.
  • A step cannot only set a working directory; use defaults.run.working-directory on the job.
  • The message may not name the step: check every dash for a run or uses, or one of the newer wait, wait-all, cancel or parallel kinds.
  • actionlint 1.7.12 reported both broken examples at the line and column of the empty step.

GitHub refuses the whole workflow file for this, so no job starts. This post covers what the message means, the causes in the order the reports show them, how to find the step when the message does not name it, and how to catch it before you push.

What does “every step must define a uses or run key” mean?

A job’s steps is a YAML list, and every dash starts a new item. Most steps either run a command (run) or call an action (uses); the newer wait, wait-all, cancel and parallel steps in GitHub’s workflow syntax reference are the only ones with neither. Everything else on a step, name, if, env, with or working-directory, describes how to do the step’s work. An item with settings and no work is what the message is about.

What causes it?

A dash too many. This is the cause in the reports I read. The author meant one step with a name and an action, and typed a dash in front of both lines, which makes two steps: the first has only a name.

steps:
  - name: Checkout source
  - uses: actions/checkout@v4   # a second step; the first has no uses or run
  - run: make test

Remove the second dash and indent the line so that uses sits under name, in the same item:

steps:
  - name: Checkout source
    uses: actions/checkout@v4
  - run: make test

A step that only sets something. A step’s own keys, such as working-directory, env or if, apply to that step only, never to the steps after it. In a GitHub Community discussion the failing workflow had a step with a name and a working-directory and nothing else, written as if it were cd. The marked answer was to delete the step and set the directory once for the job, which the workflow syntax reference documents as defaults.run.working-directory:

jobs:
  publish:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./app
    steps:
      - uses: actions/checkout@v4
      - run: make test

A step whose command was commented out or deleted. The same shape appears when the run line of a step is commented out while debugging and its name or if is left behind. Comment out or delete the whole item.

How do I find the step that is wrong?

The message may not point at it. A report on GitHub’s runner repository asked for exactly that: its author said the error did not identify the step and asked for a line number or a step name. So look for it yourself. Go down the steps list and, for every dash, check that the item contains run or uses, or is one of the newer wait, wait-all, cancel or parallel steps. Look hardest at lines that start with - name: and are followed at once by another dash.

A checker finds it faster. actionlint, an open-source workflow linter, reported both broken workflows above at the exact line and column of the empty step when I ran it, with its own wording: “step must run script with "run" section or run action with "uses" section”. Version 1.7.12 does not know the newer step kinds yet and reported a wait and a wait-all step with the same error, so a flagged step of those kinds is not a mistake.

actionlint .github/workflows/ci.yml
# ci.yml:7:9: step must run script with "run" section or run action with "uses" section

Do I need a name on every step?

No, and leaving names off removes the way this mistake is made in the reports above. The marked answer in the same discussion points out that step names are optional: GitHub’s reference says a step without one is shown by the text of its run command. A step that is one line, - uses: or - run:, cannot be split by a stray dash.

How do I catch it before pushing?

Run the checker where you edit. actionlint reads the files under .github/workflows and exits non-zero when it finds a problem, so it fits a pre-commit hook or a first job. If the file does not parse as YAML at all you get a different message, which the post on “You have an error in your yaml syntax” covers, and a context used where it is not available gives “Unrecognized named-value”. To try a workflow without pushing each change, see running GitHub Actions locally, and for when to move repeated steps out of a job, see reusable workflows or composite actions.

This error is GitHub’s reading of the workflow file, before any runner is involved, so it is the same whichever runner the job would have used, ours included. Every size we run, with its memory, disk and rate a minute, is on our managed GitHub Actions runners page.

Sources

Frequently asked questions

How do I fix "every step must define a `uses` or `run` key" in GitHub Actions?

Find the item in the job's steps list that has neither a run command nor a uses action, and merge it into its neighbour or delete it. The 2 usual causes are a stray dash that splits one step in two and a step that holds only a name or a setting.

How do I find the step that is wrong?

The message may not name it. Go down the steps list and check that every dash has a run or a uses, or is a newer wait, wait-all, cancel or parallel step. Look hardest at a name line followed at once by another dash. actionlint reports the exact line and column.

Do I need a name on every step?

No. Step names are optional, and GitHub shows a step without one by the text of its run command. A one-line step that starts with uses or run cannot be split by a stray dash.

How do I catch it before pushing?

Run actionlint on the files under .github/workflows before you commit. In our check it reported both broken examples in this post at the line and column of the empty step, and passed the corrected ones.

Move your CI onto our runners with one line

Change one line, watch your own build, then decide.

Connect GitHub

Card required: a $5.00 authorisation, released at once and never charged. 3,000 minutes a month at 2 vCPU are included.

.github/workflows/ci.yml
jobs: test:removed: runs-on: ubuntu-latestadded: runs-on: runnersio-4vcpu-ubuntu-latest steps: - uses: actions/checkout@v4 - run: make testadded: build:added: runs-on: runnersio-32vcpu-ubuntu-latest