Which expression correctly skips a step unless the workflow was triggered by a push to the 'main' branch?
Select an answer to reveal the explanation.
Short Explanation and Infographic
GitHub stores refs in full format — 'refs/heads/main' not just 'main'. Always use the full ref path in comparisons.
Full explanation below image
Full Explanation
The 'github.ref' context contains the full Git ref of the branch or tag that triggered the workflow, formatted as 'refs/heads/<branch>' for branches and 'refs/tags/<tag>' for tags. Comparing to just 'main' will always be false. 'branch' is not a valid context property. 'event.ref' is not a valid expression path. To simplify branch comparisons, you can also use 'github.ref_name' which strips the 'refs/heads/' prefix and gives just the branch name.