Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Actions Job is skipped although all needs succeeded

We do have a problem with a GitHub Actions job which is always skipped although all "needed" jobs did run successfully. That's the job:

  deploy-api:
    needs: [build-test-api, terraform-apply, set-deployment-env]
    uses: ./.github/workflows/workflow-api-deploy.yml

To verify that all needs did pass, I have added another job for debugging and printed the result of the needed jobs.

  debug-deploy-api:
    runs-on: ubuntu-latest
    needs: [build-test-api, terraform-apply, set-deployment-env]
    if: always() # Had to add this, otherwise it would be skipped just as "deploy-api".
    steps:
      - run: |
          echo "Result of build-test-api: ${{ needs.build-test-api.result }}"
          echo "Result of terraform-apply: ${{ needs.terraform-apply.result }}"
          echo "Result of set-deployment-env: ${{ needs.set-deployment-env.result }}"

The output is

Result of build-test-api: success
Result of terraform-apply: success
Result of set-deployment-env: success

I don't understand why deploy-api is skipped.

Job began to be skipped after this change

The behavior started after adding a dependency to build-test-api:

With this version of build-test-api, the deploy job did run just fine:

  build-test-api:
    uses: # reusable WF from internal repo
    needs: set-deployment-env

After changing it into

  build-test-api:
    uses: # reusable WF from internal repo
    needs: [set-deployment-env, auto-versioning]
    if: |
      always() &&
      (needs.set-deployment-env.result == 'success') &&
      (needs.auto-versioning.result == 'success' || needs.auto-versioning.result == 'skipped')

deploy-api has been skipped always. But build-test-api is, despite that change, still running fine and even appends the created artifact to the workflow run.

Activating runner and step debug logging did not reveal any insights on why the job is still skipped. Any ideas?

like image 540
Michaelvsk Avatar asked Oct 11 '25 09:10

Michaelvsk


1 Answers

Meanwhile I did contact the GitHub Premium Support and they provided a solution:

deploy-api:
  if: success('build-test-api') # This line is required, if any of the previous job did not end with status 'success'.
  needs: build-test-api
  uses: ./.github/workflows/48-reusable-workflow-2.yml

I think I also know why: The documentation says:

You can use the following status check functions as expressions in if conditionals. A default status check of success() is applied unless you include one of these functions.

And definition of success() is as follows:

Returns true when none of the previous steps have failed or been canceled.

The only issue I think is, that is should be:

Returns true when none of the previous steps have failed, canceled or skipped.

like image 58
Michaelvsk Avatar answered Oct 16 '25 08:10

Michaelvsk