From a0825e7774f2335d0abf93b4a1b13b226bd294fc Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 9 Oct 2025 21:17:42 +0800 Subject: [PATCH] Add workflow notify dist-arch update --- .../workflows/dist-update-notification.yml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/dist-update-notification.yml diff --git a/.github/workflows/dist-update-notification.yml b/.github/workflows/dist-update-notification.yml new file mode 100644 index 000000000..bc6482373 --- /dev/null +++ b/.github/workflows/dist-update-notification.yml @@ -0,0 +1,38 @@ +name: Notify Discussion on dist-arch Change + +on: + push: + paths: + - 'dist-arch/**' + +jobs: + notify-discussion: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Add comment to discussion as notification + id: notify + env: + DISCUSSION_NUMBER: 2140 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + MESSAGE="🔔 Directory \`dist-arch/\` has changed.\n" + MESSAGE+="🔗 Commit message: ${{ github.event.head_commit.message }}\n" + MESSAGE+="🔗 Commit hash: ${{ github.sha }}" + + RESPONSE=$(curl -s -X POST \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/${{ github.repository }}/discussions/${DISCUSSION_NUMBER}/comments \ + -d "{\"body\": \"$MESSAGE\"}") + + if echo "$RESPONSE" | grep -q '"id":'; then + echo "Succeed in creating comment under discussion ${DISCUSSION_NUMBER}." + echo "response=$RESPONSE" >> $GITHUB_OUTPUT + else + echo "Failed in creating comment under discussion ${DISCUSSION_NUMBER}." + echo "$RESPONSE" >&2 + exit 1 + fi