Add check if thread exist
This commit is contained in:
parent
ca35a45ecd
commit
35ddde0256
@ -80,7 +80,25 @@ jobs:
|
||||
VAR+="${{ github.event.issue.html_url }}"
|
||||
echo "message=$VAR" >> $GITHUB_ENV
|
||||
|
||||
- name: Check if Discord thread exists
|
||||
id: check_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" --arg PARENT_ID "${{ secrets.DISCORD_CHANNEL_ID }}" \
|
||||
'.threads[] | select(.parent_id == $PARENT_ID and .name == ("Wanted Tester for " + $TITLE)) | .id')
|
||||
|
||||
if [ -n "$THREAD_ID" ]; then
|
||||
echo "thread_exists=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "thread_exists=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Create a forumpost in Discord
|
||||
if: steps.check_thread.outputs.thread_exists != 'true'
|
||||
id: post_to_discord
|
||||
env:
|
||||
DISCORD_CHANNEL_ID: ${{ secrets.DISCORD_CHANNEL_ID }}
|
||||
@ -106,6 +124,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Comment on Issue
|
||||
if: steps.check_thread.outputs.thread_exists != 'true'
|
||||
id: comment_on_issue
|
||||
env:
|
||||
MESSAGE: ${{ env.message }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user