Die „immer wahr“-Falle
Am häufigstenGitHub wertet nur das aus, was innerhalb von ${{ }} steht. Außerhalb belassene Operatoren werden nach der Substitution zu literalem Text — einer nicht leeren Zeichenkette, die immer truthy ist. Der Evaluator markiert dies (actions/runner#1173).
Immer wahr
# 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 Behoben
# CORRECT — wrap the WHOLE condition in one ${{ }}
jobs:
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
# now GitHub evaluates the comparison, not a literal string