Github Actions作业被跳过

12

使用 Github Actions 进行一些 CI/CD。

目前我遇到了一些奇怪的行为,我的作业被跳过了,尽管条件已经满足。 deploy-api 有两个条件,即代码被推送到主分支和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

enter image description here

从图片中可以看到,尽管推送的是主分支(顶部显示),并且前一个作业已经成功完成,但第二个作业仍然被跳过了。

我在代码中漏掉了什么吗?有没有人知道可以使用的解决方法?

如果UI能告诉用户为什么会被跳过就好了!

2个回答

8

0
needs.test-api.status更改为needs.test-api.result

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接