Skip to content

Commit d4db8fd

Browse files
Merge pull request #22 from step-security/npm-audit-fix
chore: dist updated
2 parents 223fd69 + 118e922 commit d4db8fd

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

dist/entrypoint.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ _main() {
4242
_check_if_git_is_available
4343

4444
_switch_to_repository
45+
46+
_check_if_is_git_repository
47+
48+
_check_if_repository_is_in_detached_state
49+
4550
if "$INPUT_CREATE_GIT_TAG_ONLY"; then
4651
_log "debug" "Create git tag only";
4752
_set_github_output "create_git_tag_only" "true"
@@ -100,11 +105,26 @@ _git_is_dirty() {
100105
gitStatusMessage="$((git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}} >/dev/null ) 2>&1)";
101106
# shellcheck disable=SC2086
102107
gitStatus="$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}})";
103-
if [ $? -ne 0 ]; then
104-
_log "error" "git-status failed with:<$gitStatusMessage>";
108+
[ -n "$gitStatus" ]
109+
}
110+
111+
_check_if_is_git_repository() {
112+
if [ -d ".git" ]; then
113+
_log "debug" "Repository found.";
114+
else
115+
_log "error" "Not a git repository. Please make sure to run this action in a git repository. Adjust the `repository` input if necessary.";
105116
exit 1;
106117
fi
107-
[ -n "$gitStatus" ]
118+
}
119+
120+
_check_if_repository_is_in_detached_state() {
121+
if [ -z "$(git symbolic-ref HEAD)" ]
122+
then
123+
_log "error" "Repository is in detached HEAD state. Please make sure you check out a branch. Adjust the `ref` input accordingly.";
124+
exit 1;
125+
else
126+
_log "debug" "Repository is on a branch.";
127+
fi
108128
}
109129
110130
_add_files() {

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)