Browse Source

Merge pull request #8967 from nextcloud/fix-delete-snapshot-comments

Fix old screenshot test comments deletion
Álvaro Brey 3 năm trước cách đây
mục cha
commit
d8fe4cc0a0
2 tập tin đã thay đổi với 29 bổ sung0 xóa
  1. 2 0
      .github/workflows/screenShotTest.yml
  2. 27 0
      scripts/deleteOldComments.sh

+ 2 - 0
.github/workflows/screenShotTest.yml

@@ -23,6 +23,8 @@ jobs:
                     mkdir -p $HOME/.gradle
                     echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
                     ./gradlew assembleGplayDebug
+            -   name: Delete old comments
+                run: scripts/deleteOldComments.sh "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
             -   name: run tests
                 uses: reactivecircus/android-emulator-runner@v2
                 with:

+ 27 - 0
scripts/deleteOldComments.sh

@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+#1: BRANCH
+#2: TYPE
+#3: PR
+#4: GITHUB_TOKEN
+
+BRANCH=$1
+TYPE=$2
+PR=$3
+GITHUB_TOKEN=$4
+
+BRANCH_TYPE=$BRANCH-$TYPE
+
+ # delete all old comments, matching this type
+echo "Deleting old comments for $BRANCH_TYPE"
+oldComments=$(curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -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 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
+  done
+fi
+
+exit 0