Skip to content

πŸ› Fixes issue notification logic #9

πŸ› Fixes issue notification logic

πŸ› Fixes issue notification logic #9

name: Report Bug-type issues to Discord
on:
issues:
types: [opened]
jobs:
notify_discord:

Check failure on line 8 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 8
runs-on: ubuntu-latest
# Run only for Bug issues AND when Skip notify Discord is NOT checked
if: ${{
contains(github.event.issue.body, 'issue-type=bug') &&
!contains(github.event.issue.body, '- [x] Skip notify Discord')
}}
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: |
SHORT_BODY=$(printf '%s' "$ISSUE_BODY" | head -c 400)
[ -z "$SHORT_BODY" ] && SHORT_BODY="(no description)"
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"