Github action job fire when previous job skipped

Viewed 652

While setting up my GitHub action to build and deploy my apps, I'm running into the following issue.

I want to deploy my web app under the following conditions below. However, whenever deploy-api and deploy-sync skip deploy-web is also skipped. I figured that my if condition would catch that case and still run deploy-web but it isn't. Feels like I'm missing something obvious but can't identify it.

deploy-web:
  name: Deploy Web
  runs-on: ubuntu-latest
  needs: [build-and-publish-web, deploy-api, deploy-sync]
  if: |
    needs.build-and-publish-web.result == 'success' &&
    (needs.deploy-api.result == 'success' || needs.deploy-api.result == 'skipped') &&
    (needs.deploy-sync.result == 'success' || needs.deploy-sync.result == 'skipped')
1 Answers

It seems like you encounter this issue - Job-level "if" condition not evaluated correctly if job in "needs" property is skipped.

Please try with always expression:

deploy-web:
  name: Deploy Web
  runs-on: ubuntu-latest
  needs: [build-and-publish-web, deploy-api, deploy-sync]
  if: |
    always() &&
    needs.build-and-publish-web.result == 'success' &&
    (needs.deploy-api.result == 'success' || needs.deploy-api.result == 'skipped') &&
    (needs.deploy-sync.result == 'success' || needs.deploy-sync.result == 'skipped')
Related