Le piège du « toujours vrai »
Le plus courantGitHub n’évalue que ce qui se trouve à l’intérieur des ${{ }}. Les opérateurs laissés à l’extérieur deviennent du texte littéral après substitution — une chaîne non vide, qui est toujours vraie. L’évaluateur le signale (actions/runner#1173).
Toujours vrai
# ALWAYS TRUE — operators sit OUTSIDE ${{ }}
jobs:
deploy:
if: ${{ github.ref }} == 'refs/heads/main'
# after substitution this is the literal string
# refs/heads/main == 'refs/heads/main'
# a non-empty string => truthy => runs on EVERY branch Corrigé
# CORRECT — wrap the WHOLE condition in one ${{ }}
jobs:
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
# now GitHub evaluates the comparison, not a literal string