Skip to content

Commit 42e918b

Browse files
committed
clean
1 parent d6cda48 commit 42e918b

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,23 @@ jobs:
6363
sudo apt-get install shellcheck
6464
6565
- name: Run pre-commits
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6668
run: |
69+
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
70+
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
71+
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
72+
6773
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 .)
6874
LAST_SHA=$(git log --pretty=tformat:"%H" -n2 | tail -n1)
6975
git fetch
70-
echo $GITHUB_REF
71-
echo $LAST_SHA
72-
if [[ $GITHUB_REF == 'refs/heads/main' ]]; then
76+
77+
echo "Default branch is $DEFAULT_BRANCH"
78+
echo "Current SHA is $CUR_SHA"
79+
echo "Last SHA is $LAST_SHA"
80+
81+
if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
7382
pre-commit run --from-ref $LAST_SHA --to-ref $CUR_SHA
7483
else
75-
pre-commit run --from-ref origin/main --to-ref $CUR_SHA
84+
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
7685
fi

0 commit comments

Comments
 (0)