GITHUB_HEAD_REFとは?
GITHUB_HEAD_REFは、pull requestのhead(ソース)branch名です - pull_requestイベントでのみ設定されます。
pull_requestの実行では、GITHUB_HEAD_REFはPRの元となるbranchであり、GITHUB_BASE_REFはPRが対象とするbranchです。pushイベントでは空になります。
いつ設定されるか
pull_requestとpull_request_targetのイベントでのみ設定されます。pushイベントでは空です。
例
PRのbranchにちなんで名付けたpreviewをbuildする。
shell
echo "Building PR from ${GITHUB_HEAD_REF}"重要なポイント
- GITHUB_HEAD_REFはPRのソースbranchです。
- pull_requestイベントでのみ設定されます。
- GITHUB_BASE_REF(対象branch)と組み合わせます。
関連ガイド
What Is GITHUB_BASE_REF?GITHUB_BASE_REF is the target branch of a pull request in GitHub Actions. Learn how it is used in diffs and m…
What Is a Pull Request?What is a pull request? An explainer on how PRs propose changes, gather review, run CI checks, and serve as t…
What Is GITHUB_REF_NAME?GITHUB_REF_NAME is the short branch or tag name for a GitHub Actions run, like main or v1.2.0. Learn how it d…