ProxmoxVED/.github/workflows/delete-discord-thread.yml
Michel Roegl-Brunner c3f73291a3
Some checks failed
Auto Update .app-files / update-app-files (push) Has been cancelled
Shellcheck / Shellcheck (push) Has been cancelled
Create Changelog Pull Request / update-changelog-pull-request (push) Has been cancelled
Close Discussion on PR Merge / close-discussion (push) Has been cancelled
Sync to Gitea / sync (push) Has been cancelled
Changes to Workfows
2025-05-13 14:19:16 +02:00

30 lines
1.1 KiB
YAML

name: Delete Discord Thread on GitHub Issue Closure
on:
issues:
types:
- closed
jobs:
close_discord_thread:
if: github.repository == 'community-scripts/ProxmoxVED'
runs-on: ubuntu-latest
steps:
- name: Get thread-ID op and close thread
run: |
ISSUE_TITLE="${{ github.event.issue.title }}"
THREAD_ID=$(curl -s -X GET "https://discord.com/api/v10/guilds/${{ secrets.DISCORD_GUILD_ID }}/threads/active" \
-H "Authorization: Bot ${{ secrets.DISCORD_BOT_TOKEN }}" \
-H "Content-Type: application/json" | \
jq -r --arg TITLE "$ISSUE_TITLE" '.threads[] | select(.parent_id == "${{ secrets.DISCORD_CHANNEL_ID }}" and .name == ("Wanted Tester for " + $TITLE)) | .id')
if [ -n "$THREAD_ID" ]; then
echo "Thread found: $THREAD_ID. Archiving..."
curl -X DELETE "https://discord.com/api/v10/channels/$THREAD_ID" \
-H "Authorization: Bot ${{ secrets.DISCORD_BOT_TOKEN }}"
else
echo "No thread found for issue: $ISSUE_TITLE"
fi