Matt Bart
Matt Bart

Reputation: 939

Github Actions Job being skipped

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!

Upvotes: 17

Views: 27678

Answers (2)

Pash
Pash

Reputation: 1

Change needs.test-api.status to needs.test-api.result

Upvotes: 0

riQQ
riQQ

Reputation: 12723

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.

Upvotes: 10

Related Questions