12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- name: Discord Issue Notification
- on:
- issues:
- types: [opened, reopened, closed]
- jobs:
- Discord:
- runs-on: ubuntu-latest
- name: Discord Issue Notifier
- steps:
- - name: Determine action color and emoji
- id: action-info
- run: |
- case "${{ github.event.action }}" in
- "opened")
- echo "color=15158332" >> $GITHUB_OUTPUT # Red
- echo "emoji=🔴" >> $GITHUB_OUTPUT
- echo "action_text=Opened" >> $GITHUB_OUTPUT
- ;;
- "reopened")
- echo "color=16776960" >> $GITHUB_OUTPUT # Yellow
- echo "emoji=🟡" >> $GITHUB_OUTPUT
- echo "action_text=Reopened" >> $GITHUB_OUTPUT
- ;;
- "closed")
- echo "color=5763719" >> $GITHUB_OUTPUT # Green
- echo "emoji=🟢" >> $GITHUB_OUTPUT
- echo "action_text=Closed" >> $GITHUB_OUTPUT
- ;;
- esac
- - name: Create Discord webhook payload
- run: |
- # Create a temporary JSON file
- cat > discord_payload.json << 'EOF'
- {
- "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
- "embeds": [
- {
- "title": "${{ steps.action-info.outputs.emoji }} Issue ${{ steps.action-info.outputs.action_text }}: #${{ github.event.issue.number }}",
- "description": "${{ github.event.issue.title }}",
- "url": "${{ github.event.issue.html_url }}",
- "color": ${{ steps.action-info.outputs.color }},
- "thumbnail": {
- "url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
- },
- "fields": [
- {
- "name": "📋 Issue #",
- "value": "`#${{ github.event.issue.number }}`",
- "inline": true
- },
- {
- "name": "👤 Author",
- "value": "[${{ github.event.issue.user.login }}](${{ github.event.issue.user.html_url }})",
- "inline": true
- },
- {
- "name": "📁 Repository",
- "value": "[${{ github.event.repository.name }}](${{ github.event.repository.html_url }})",
- "inline": true
- },
- {
- "name": "🏷️ Labels",
- "value": "${{ github.event.issue.labels[0].name && join(github.event.issue.labels.*.name, ', ') || 'None' }}",
- "inline": true
- },
- {
- "name": "📊 State",
- "value": "`${{ github.event.issue.state }}`",
- "inline": true
- },
- {
- "name": "🔗 View Issue",
- "value": "[Issue Page](${{ github.event.issue.html_url }})",
- "inline": true
- }
- ],
- "timestamp": "${{ github.event.issue.created_at }}",
- "footer": {
- "text": "Workout Cool • Issue ${{ steps.action-info.outputs.action_text }}",
- "icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
- }
- }
- ]
- }
- EOF
- - name: Send Discord notification
- run: |
- curl -H "Content-Type: application/json" \
- -d @discord_payload.json \
- "${{ secrets.DISCORD_ISSUES_WEBHOOK }}"
|