Skip to content

Commit

Permalink
fix commit list
Browse files Browse the repository at this point in the history
Signed-off-by: Inho Oh <[email protected]>
  • Loading branch information
webispy committed Oct 22, 2019
1 parent cbc9d8b commit 005cc8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 4 additions & 2 deletions review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
{
"commit_id": "$COMMIT",
Expand All @@ -40,7 +41,8 @@ EOF
# Write message to pull-request comment
function post_comment_message()
{
curl $BODY_URL -s -H "Authorization: token ${GITHUB_TOKEN}" \
echo "POST to ${BODY_URL} with ${MESSAGE}"
curl ${BODY_URL} -H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-X POST --data "$(cat <<EOF
{
Expand Down

0 comments on commit 005cc8a

Please sign in to comment.