Skip to content

Commit 420d4a9

Browse files
committed
fix: Switch to git to get all commits
The ${GITHUB_EVENT_PATH} JSON file only shows diff since last push, not all commits for the entire feature branch.
1 parent 733aed1 commit 420d4a9

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.github/workflows/git.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ jobs:
77
runs-on: ubuntu-18.04
88

99
steps:
10+
- uses: actions/checkout@master
1011
- name: Block Fixup Merge
1112
uses: 13rac1/block-fixup-merge-action@master

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM alpine:3.10
22

33
RUN apk add --no-cache \
44
bash \
5-
jq
5+
git
66
COPY entrypoint.sh /entrypoint.sh
77

88
CMD ["/entrypoint.sh"]

entrypoint.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
set -e
33
set -o pipefail
44
main() {
5-
echo "Current branch: ${GITHUB_REF}"
5+
echo "Current ref: ${GITHUB_REF}"
6+
echo "Current branch: ${GITHUB_REF:11}"
7+
# Using git directly because the $GITHUB_EVENT_PATH file only shows commits in
8+
# most recent push.
69

7-
FIXUP_COUNT=`jq .commits[].message ${GITHUB_EVENT_PATH} | grep fixup! | wc -l || true`
10+
FIXUP_COUNT=`git log --pretty=format:%s origin/master..origin/${GITHUB_REF:11} | grep fixup! | wc -l || true`
811
echo "Fixup! commits: ${FIXUP_COUNT}"
912
if [ "$FIXUP_COUNT" -gt "0" ]; then
10-
echo "Found Fixup! commits, failing"
13+
git log --pretty=format:%s origin/master..origin/${GITHUB_REF:11} | grep fixup!
14+
echo "failing..."
1115
exit 1
1216
fi
1317
}

0 commit comments

Comments
 (0)