Skip to content

Commit c66eb19

Browse files
MarkoSagadinTjazVracko
authored andcommitted
fix(infra): restructure first commit check in pre-commit workflow
This will avoid case where the second part of the each if condition could resolve to empty string and break the bash syntax.
1 parent 5eeeac4 commit c66eb19

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,20 @@ jobs:
3131
# Fetch commit refs.
3232
first="0000000000000000000000000000000000000000"
3333
34-
if [[ ${{ github.event_name }} == 'push' && ${{ github.event.before }} == $first ]]; then
35-
echo "This is the first commit in the repository. No commits to check."
36-
echo "skip_pre-commit=true" >> $GITHUB_OUTPUT
37-
elif [[ ${{ github.event_name }} == 'pull_request' && $(git rev-parse origin/${{ github.base_ref }}) == $first ]]; then
38-
echo "This is the first commit in the repository. No commits to check."
39-
echo "skip_pre-commit=true" >> $GITHUB_OUTPUT
34+
if [[ ${{ github.event_name }} == 'push' ]]; then
35+
if [[ ${{ github.event.before }} == $first ]]; then
36+
echo "This is the first commit in the repository. No commits to check."
37+
echo "skip_pre-commit=true" >> $GITHUB_OUTPUT
38+
else
39+
echo "skip_pre-commit=false" >> $GITHUB_OUTPUT
40+
fi
41+
elif [[ ${{ github.event_name }} == 'pull_request' ]]; then
42+
if [[ $(git rev-parse origin/${{ github.base_ref }}) == $first ]];then
43+
echo "This is the first commit in the repository. No commits to check."
44+
echo "skip_pre-commit=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "skip_pre-commit=false" >> $GITHUB_OUTPUT
47+
fi
4048
else
4149
echo "skip_pre-commit=false" >> $GITHUB_OUTPUT
4250
fi

0 commit comments

Comments
 (0)