π Fixes issue notification logic #9
This file contains hidden or 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: Report Bug-type issues to Discord | ||
| on: | ||
| issues: | ||
| types: [opened] | ||
| jobs: | ||
| notify_discord: | ||
| 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" | ||