A armadilha do "sempre verdadeiro"
Mais comumO GitHub só avalia o que está dentro de ${{ }}. Os operadores deixados de fora viram texto literal após a substituição — uma string não vazia, que é sempre truthy. O avaliador sinaliza isso (actions/runner#1173).
Sempre verdadeiro
# 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 Corrigido
# CORRECT — wrap the WHOLE condition in one ${{ }}
jobs:
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
# now GitHub evaluates the comparison, not a literal string