简体   繁体   English

GitHub 操作无效的工作流文件错误

[英]GitHub Actions Invalid Workflow File Error

I started using GitHub Actions and I was able to setup a CI pipeline for Elixir, the action builds and tests without any issues.我开始使用 GitHub 操作,我能够为 Elixir 设置 CI 管道,操作构建和测试没有任何问题。 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:我还想使用 heroku 操作部署应用程序,因此我继续添加了 GitHub 中可用的应用程序,但这样做之后我收到以下错误:

Invalid Workflow File Every step must define a uses or run key无效的工作流文件每个步骤都必须定义一个使用或运行键

This is how my workflow looked before adding the heroku action:这是我的工作流程在添加 heroku 操作之前的样子:

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/checkout@v1.0.0
      - uses: actions/setup-elixir@v1.0.0
        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这就是我添加 heroku 动作的方式

  deploy:

      runs-on: ubuntu-latest

      steps:
        - uses: actions/heroku@1.0.0
        - name: GitHub Action for Heroku    
        - run: |
            heroku login

          env:
            CI: true

Here is the error for more details. 是有关更多详细信息的错误。

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. actions/heroku的自述文件尚未更新以显示 yaml 工作流的示例。 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

In addition to @peterevans, also check the indentation, it is important:除了@peterevans,还要检查缩进,这很重要:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM