Skip to content

Commit 881a632

Browse files
authored
feat: Adjust the detached HEAD documentation (#376)
1 parent f917f9b commit 881a632

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

start.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,24 @@ fi
4949

5050
cd ${INPUT_DIRECTORY}
5151

52+
if git symbolic-ref --quiet HEAD > /dev/null 2>&1; then
53+
_DETACHED_HEAD=false
54+
else
55+
_DETACHED_HEAD=true
56+
fi
57+
58+
if ${_DETACHED_HEAD}; then
59+
echo "Warning: The repository is in a detached HEAD state.";
60+
echo "This happens when actions/checkout checks out a tag, a commit SHA, or a";
61+
echo "pull-request merge commit rather than a real branch.";
62+
echo "To resolve this, check out a branch explicitly in your actions/checkout step,";
63+
echo "for example: 'ref: \${{ github.head_ref }}' or 'ref: main'.";
64+
echo "Note: setting this action's 'branch' input (e.g. branch: main) only controls";
65+
echo "the push destination — it does not check out a branch in your workspace.";
66+
fi
67+
5268
if [ "${INPUT_PULL}" != "false" ]; then
53-
if ! git symbolic-ref --quiet HEAD > /dev/null 2>&1; then
69+
if ${_DETACHED_HEAD}; then
5470
echo "Error: 'pull' is enabled but the repository is in detached HEAD state."
5571
echo "git pull only works when a branch is currently checked out."
5672
echo "Either disable the 'pull' input or check out a branch explicitly"

0 commit comments

Comments
 (0)