GitHub Actions: github.ref_name vs github.head_ref

Oct 18, 2023 · 1 min read · Post a comment

GitHub has its own contexts that you could use while working with GitHub actions which you could use in certain scenarios. The most confusing thing I stumble upon was choosing between github.head_refand github.ref_name. Which one is it?


  • GitHub


  • github.ref_name: points to the branch or the tag that triggered the workflow run.
  • github.head_ref: points to the source branch of the PR. This only works for pull requests and that’s the key point.


In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.