Testing Threads #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Discord Thread from Issue | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
create-discord-thread: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create Discord Thread | |
env: | |
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }} | |
DISCORD_CHANNEL_ID: ${{ secrets.DISCORD_CHANNEL_ID }} | |
run: | | |
# Create initial message | |
MESSAGE_RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: Bot $DISCORD_BOT_TOKEN" \ | |
-H "Content-Type: application/json" \ | |
"https://discord.com/api/v10/channels/$DISCORD_CHANNEL_ID/messages" \ | |
-d "{ | |
\"content\": \"New Issue: ${{ github.event.issue.title }}\", | |
\"embeds\": [{ | |
\"title\": \"${{ github.event.issue.title }}\", | |
\"url\": \"${{ github.event.issue.html_url }}\", | |
\"description\": \"${ISSUE_BODY:0:2000}\", | |
\"color\": 5814783 | |
}] | |
}") | |
# Get message ID | |
MESSAGE_ID=$(echo "$MESSAGE_RESPONSE" | jq -r '.id') | |
# Create thread | |
THREAD_RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: Bot $DISCORD_BOT_TOKEN" \ | |
-H "Content-Type: application/json" \ | |
"https://discord.com/api/v10/channels/$DISCORD_CHANNEL_ID/messages/$MESSAGE_ID/threads" \ | |
-d "{ | |
\"name\": \"${ISSUE_TITLE:0:100}\", | |
\"auto_archive_duration\": 1440 | |
}") |