GitHub Actions Invalid Workflow File Error
Asked Answered
C

2

35

I started using GitHub Actions and I was able to setup a CI pipeline for Elixir, the action builds and tests without any issues. I also wanted to deploy the application using the heroku actions so I went ahead and added the one that is available in GitHub but after doing that I'm getting the following error:

Invalid Workflow File Every step must define a uses or run key

This is how my workflow looked before adding the heroku action:

name: Elixir CI

on: push

jobs:
  build:

    runs-on: ubuntu-latest

    container:
      image: elixir:1.9.1-slim

    steps:
    - uses: actions/checkout@v1
    - name: Install Dependencies
      run: |
        mix local.rebar --force
        mix local.hex --force
        mix deps.get

  test:

    runs-on: ubuntu-latest

    services:
      db:
        image: postgres:11
        ports: ['5432:5432']
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      - uses: actions/[email protected]
      - uses: actions/[email protected]
        with:
          otp-version: 22.x
          elixir-version: 1.9.x
      - run: mix deps.get
      - run: mix test

And this is how I added the heroku action

  deploy:

      runs-on: ubuntu-latest

      steps:
        - uses: actions/[email protected]
        - name: GitHub Action for Heroku    
        - run: |
            heroku login

          env:
            CI: true

Here is the error for more details.

Colver answered 14/11, 2019 at 5:10 Comment(0)
D
52

You have too many - where you are defining the step. There should only be one - per step in the job.

The README for actions/heroku hasn't been updated yet to show an example for yaml workflows. There is an open pull request to update it though. The following is the example from that pull request which might help you.

on: push
name: Deploy to Heroku
jobs:
  release:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: login
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: container:login
    - name: push
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: container:push -a calm-fortress-1234 web
    - name: release
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: container:release -a calm-fortress-1234 web
Dehydrogenase answered 14/11, 2019 at 5:31 Comment(2)
Apparently only the "uses" lines count as "steps" in the job. Dashes in front of name are fine (?!) but only the first uses can take a dash.Aryanize
And the error message is "sooooooooooo" helpful. I hate yaml, so easy to make a mistake and not know about it until so much later so often.Foti
R
2

In addition to @peterevans, also check the indentation, it is important:

https://github.community/t/run-failing-invalid-workflow-file/127574

Revenge answered 6/7, 2022 at 11:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.