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

Fra*_*iaz 26 github github-actions

我开始使用 GitHub Actions,我能够为 Elixir 设置 CI 管道,操作构建和测试没有任何问题。我还想使用 heroku 操作部署应用程序,所以我继续添加了 GitHub 中可用的应用程序,但在这样做之后,我收到以下错误:

无效的工作流文件每一步都必须定义一个使用或运行密钥

这是我的工作流程在添加 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

Run Code Online (Sandbox Code Playgroud)

这就是我添加 heroku 动作的方式

  deploy:

      runs-on: ubuntu-latest

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

          env:
            CI: true
Run Code Online (Sandbox Code Playgroud)

是更多详细信息的错误。

pet*_*ans 39

-在定义步骤的地方太多了。-工作中的每一步应该只有一个。

actions/heroku尚未更新README以显示 yaml 工作流的示例。不过有一个开放的拉取请求来更新它。以下是该拉取请求的示例,可能对您有所帮助。

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
Run Code Online (Sandbox Code Playgroud)

  • 显然,只有“使用”行才算作工作中的“步骤”。“name”前面的破折号可以(?!),但只有第一个“uses”可以使用破折号。 (2认同)