|
@@ -1,15 +1,21 @@
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
+curl_gh() {
|
|
|
+ curl \
|
|
|
+ --header "authorization: Bearer $GITHUB_TOKEN" \
|
|
|
+ "$@"
|
|
|
+}
|
|
|
+
|
|
|
deleteOldComments() {
|
|
|
# delete all old comments, matching this type
|
|
|
echo "Deleting old comments for $BRANCH_TYPE"
|
|
|
- oldComments=$(curl > /dev/null 2>&1 -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
|
|
+ oldComments=$(curl_gh > /dev/null 2>&1 -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
|
|
count=$(echo $oldComments | grep true | wc -l)
|
|
|
echo "Found $count old comments"
|
|
|
|
|
|
echo $oldComments | while read comment ; do
|
|
|
echo "Deleting comment: $comment"
|
|
|
- curl > /dev/null 2>&1 -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
|
|
+ curl_gh > /dev/null 2>&1 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
|
|
done
|
|
|
}
|
|
|
|
|
@@ -23,7 +29,7 @@ upload() {
|
|
|
|
|
|
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
|
|
|
|
|
|
- curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
|
|
+ curl_gh -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
|
|
-d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
|
|
|
|
|
exit 1
|
|
@@ -71,7 +77,7 @@ else
|
|
|
deleteOldComments
|
|
|
echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
|
|
|
|
|
- curl > /dev/null 2>&1 -u $GITHUB_USER:$GITHUB_PASSWORD \
|
|
|
+ curl_gh > /dev/null 2>&1 \
|
|
|
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
|
|
-d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
|
|
|