try travis PR comments
This commit is contained in:
parent
912ccb6b68
commit
e58b818223
2 changed files with 29 additions and 0 deletions
28
comment.sh
Executable file
28
comment.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
PR_NR=$TRAVIS_PULL_REQUEST
|
||||
|
||||
function performQuery() {
|
||||
NEW_QUERY_STR="{\"query\":\"$1\"}"
|
||||
curl -s -H "Authorization: bearer $COMMENT_TOKEN" -X POST -d $NEW_QUERY_STR https://api.github.com/graphql
|
||||
}
|
||||
|
||||
RESULT=$(performQuery "{repository(owner:\\\"ZeusWPI\\\",name:\\\"zeus.ugent.be\\\"){pullRequest(number:$PR_NR){id,comments(first:10){nodes{author{login}}}}}}")
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "QUERY FAILED, RESULT: $RESULT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the GraphQL ID
|
||||
PR_ID=$(echo $RESULT | sed 's/.*"id":"\([^"]*\)".*/\1/')
|
||||
|
||||
# TODO: Have another user do the commenting
|
||||
if [[ $RESULT == *"werthen"* ]]; then
|
||||
echo "User has already commented"
|
||||
else
|
||||
ADD_COMMENT_STR="mutation{addComment(input:{subjectId:\\\"$PR_ID\\\",body:\\\"Check out the preview on https://$PR_NR.pr.zeus.gent/\\\"}){clientMutationId}}"
|
||||
performQuery $ADD_COMMENT_STR
|
||||
fi
|
||||
|
||||
|
|
@ -8,4 +8,5 @@ if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then
|
|||
fi
|
||||
else
|
||||
rsync -e 'ssh -p 2222' -aglpPrtvz --delete output/ "zeuspr@herbert.ugent.be:/home/zeuspr/public/$TRAVIS_PULL_REQUEST/"
|
||||
./comment.sh
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue