Skip to content

πŸ› Updates issue type check in workflow #7

πŸ› Updates issue type check in workflow

πŸ› Updates issue type check in workflow #7

name: Report Bug-type issues to Discord
on:
issues:
types: [opened]
jobs:
notify_discord:
runs-on: ubuntu-latest
# Only run for issues whose type is "Bug"
if: contains(github.event.issue.body, 'issue-type: task')

Check failure on line 12 in .github/workflows/issue-bug-to-discord.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/issue-bug-to-discord.yml

Invalid workflow file

You have an error in your yaml syntax on line 12
steps:
- name: Send Discord notification
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_URL: ${{ github.event.issue.html_url }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_USER: ${{ github.event.issue.user.login }}
REPO_NAME: ${{ github.repository }}
run: |
# Trim body to avoid huge messages
SHORT_BODY=$(printf '%s' "$ISSUE_BODY" | head -c 400)
[ -z "$SHORT_BODY" ] && SHORT_BODY="(no description)"
# Build JSON payload for Discord
payload=$(jq -n \
--arg username "GitHub Bot" \
--arg content "" \
--arg title "πŸ› New Bug issue in $REPO_NAME" \
--arg desc "**#${ISSUE_NUMBER} – $ISSUE_TITLE**\n"\
"**Author:** $ISSUE_USER\n"\
"**Link:** $ISSUE_URL\n\n"\
"**Description (truncated):**\n$SHORT_BODY" \
'{
"username": $username,
"content": $content,
"embeds": [
{
"title": $title,
"description": $desc
}
]
}')
curl -X POST \
-H "Content-Type: application/json" \
-d "$payload" \
"$DISCORD_WEBHOOK_URL"