forked from Elv1zz/nextcloud-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteOldComments.sh
More file actions
executable file
·27 lines (21 loc) · 844 Bytes
/
Copy pathdeleteOldComments.sh
File metadata and controls
executable file
·27 lines (21 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
#1: BRANCH
#2: TYPE
#3: PR
BRANCH=$1
TYPE=$2
PR=$3
source scripts/lib.sh
BRANCH_TYPE=$BRANCH-$TYPE
# delete all old comments, matching this type
echo "Deleting old comments for $BRANCH_TYPE"
oldComments=$(curl_gh -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|github-actions)") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
count=$(echo -n "$oldComments" | grep -c '^')
echo "Found $count old comments"
if [ "$count" -gt 0 ]; then
echo "$oldComments" | while read comment ; do
echo "Deleting comment: $comment"
curl_gh -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
done
fi
exit 0