【问题标题】:Github Actions Job being skippedGithub Actions 作业被跳过
【发布时间】:2021-05-13 16:51:40
【问题描述】:

将 Github Actions 用于某些 CI/CD。

目前,我遇到了一些奇怪的行为,即尽管满足了条件,但我的工作却被跳过了。 deploy-api 有两个条件,如果代码被推送到 master 并且 test-api 是成功的。但即使我们满足了这些条件,它仍然被跳过。

jobs:
  test-api:
    name: Run tests on API
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - name: Get dependencies
        run: npm install
        working-directory: ./api
      - name: Run tests
        run: npm run test
        working-directory: ./api

  deploy-api:
    needs: test-api # other job must finish
    if: github.ref == 'refs/heads/master' && needs.test-api.status == 'success' #only run if it's a commit to master AND previous success

如图所示,尽管推送在主分支上(如顶部所示)并且前一个作业成功,但第二个作业被跳过。

我是否在代码中遗漏了什么?有谁知道可以使用的解决方法?

如果用户界面告诉用户它被跳过的原因,那就太好了!

【问题讨论】:

    标签: github continuous-integration github-actions


    【解决方案1】:

    if 表达式中使用needs.test-api.result == 'success'(没有.status)。

    https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context

    【讨论】:

      猜你喜欢
      • 2020-05-02
      • 2022-11-08
      • 2021-04-03
      • 2021-09-23
      • 2021-08-28
      • 2022-07-10
      • 1970-01-01
      • 2022-01-23
      • 2021-04-10
      相关资源
      最近更新 更多