Skip to content

Commit bf77a3b

Browse files
committed
Fail in Update workflow if push event has detached HEAD
1 parent c160d48 commit bf77a3b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/workflows/update.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ jobs:
4747
env:
4848
GITHUB_EVENT_NAME: ${{ github.event_name }}
4949
run: |
50+
if [[ $GITHUB_EVENT_NAME == 'push' ]]; then
51+
if git status -s -b | grep -q '^##.*(no branch)$'; then
52+
echo 2>&1 "Error: Git is in detached HEAD state"
53+
exit 1
54+
fi
55+
fi
56+
5057
if [ -n "$(git status --porcelain 'nix/')" ]; then
5158
if [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
5259
echo 2>&1 "Error: found modified files"
@@ -103,6 +110,13 @@ jobs:
103110
env:
104111
GITHUB_EVENT_NAME: ${{ github.event_name }}
105112
run: |
113+
if [[ $GITHUB_EVENT_NAME == 'push' ]]; then
114+
if git status -s -b | grep -q '^##.*(no branch)$'; then
115+
echo 2>&1 "Error: Git is in detached HEAD state"
116+
exit 1
117+
fi
118+
fi
119+
106120
if [ -n "$(git status --porcelain '*.hs')" ]; then
107121
if [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
108122
echo 2>&1 "Error: found modified files"

0 commit comments

Comments
 (0)