How do I use multiple "uses" in a named step

Try to set the npm version from the the reference that triggers the actions with the following script

jobs:
  version:
    runs-on: ubuntu-latest
    steps:
      - name: Set Result
        uses: actions/github-script@v3
        id: set-result
        with:
          script: return context.ref.replace('/refs/tags/', '')
          result-encoding: string
      - name: Set Version
         uses: actions/checkout@v2 # error
         uses: actions/setup-node@v2 # error
         with:
           node-version: '14.x'
      - run: npm version --no-git-tag-version "${{steps.set-result.outputs.result}}"

Github complains about duplicate key “uses”. I’m clearly missing something. I can do this just fine in an unnamed step:

  build:
    needs: version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '14.x'
      - run: npm ci

How do I fix my Set-Version step so that it can use both actions/checkout and actions/setup-node?

1 Like

Each step can only execute a single action. A “uses” statement is executing an action, such as the Checkout action or the setup-node action. You can’t combine them into one step like you are doing. They have to be two steps:

- name: Checkout Code
  uses: actions/checkout@v2

- name: Set Version
  uses: actions/setup-node@v2
4 Likes

Thank you! That clears things up and I got my actions working.

1 Like