From 005cc8ad5e5748e6081c72dcdae6700113123271 Mon Sep 17 00:00:00 2001 From: Inho Oh Date: Tue, 22 Oct 2019 13:08:51 +0900 Subject: [PATCH] fix commit list Signed-off-by: Inho Oh --- entrypoint.sh | 12 ++++++++++-- review.sh | 6 ++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index d094d0e..3e8699e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,13 +12,21 @@ echo "SHA: $GITHUB_SHA" echo "REF: $GITHUB_REF" echo "HEAD-REF: $GITHUB_HEAD_REF" echo "BASE-REF: $GITHUB_BASE_REF" -echo "TOKEN: $GITHUB_TOKEN" pwd RESULT=0 +# Get PR number +PR=${GITHUB_REF#"refs/pull/"} +PRNUM=${PR%"/merge"} + +# Get commit list using Github API +URL=https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PRNUM}/commits +list=$(curl $URL -X GET -s -H "Authorization: token ${GITHUB_TOKEN}" | jq '.[].sha' -r) +echo $list + # Run review.sh on each commit in the PR -for sha1 in $(git rev-list origin/$GITHUB_BASE_REF..origin/$GITHUB_HEAD_REF); do +for sha1 in $list; do echo "Check - Commit id $sha1" /review.sh ${sha1} || RESULT=1; echo "Result: ${RESULT}" diff --git a/review.sh b/review.sh index e831c43..b440f67 100755 --- a/review.sh +++ b/review.sh @@ -25,7 +25,8 @@ MESSAGE= # Write message to specific file and line function post_code_message() { - curl $CODE_URL -s -H "Authorization: token ${GITHUB_TOKEN}" \ + echo "POST to ${CODE_URL} with ${MESSAGE}" + curl ${CODE_URL} -H "Authorization: token ${GITHUB_TOKEN}" \ -X POST --data "$(cat <