November 21, 2026 路 #66
Deployed with failing tests
Tests failed on main, and the deploy still went out. Which line overrides the dependency?
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test
deploy:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- uses: actions/checkout@v4
- run: ./scripts/deploy.shNext puzzle in UTC
One try. The first answer sticks.
How to fix it
needs normally skips a job when a dependency fails. An if with always() replaces that default, so deploy runs no matter what. Use success() or drop the if.
By default a job with needs gets an implicit if: success(). Writing always() replaces it, so the deploy runs after a failed or cancelled test job. Someone probably added it so a notification step would run, and it changed the meaning of the whole job. needs: test and needs: [test] are equivalent.
Fix
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
notify:
needs: [test, deploy]
if: always()
runs-on: ubuntu-latest
Keep always() for jobs that report or clean up. When you add a custom condition to a deploy job, include success() explicitly, for example if: success() && github.ref == 'refs/heads/main'.