Answer a question

Using Github Actions for some CI/CD.

Currently I am experiencing strange behavior where my jobs are being skipped despite the conditions being met. deploy-api has two conditions, if code was pushed to master and test-api was a success. But even though we are meeting those conditions, it is still being skipped.

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

As seen in the picture the second job is being skipped despite the push being on the master branch (as seen on the top) AND the previous job being successful.

Am I missing something in the code? Does anyone know of a workaround that can be used?

It would be nice if the UI told the user why it was skipped!

Answers

Use needs.test-api.result == 'success' (there is no .status) in the if expression.

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

Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐