|
| 1 | +name: Discord Webhook Integration |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + issues: |
| 7 | + types: [opened, closed] |
| 8 | + pull_request: |
| 9 | + types: [opened, closed, merged] |
| 10 | + push: |
| 11 | + branches: [main] |
| 12 | + paths: |
| 13 | + - 'CHANGELOG.md' |
| 14 | + - 'cli/Cargo.toml' |
| 15 | + |
| 16 | +env: |
| 17 | + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + release-announcement: |
| 21 | + name: Release Announcement |
| 22 | + runs-on: ubuntu-latest |
| 23 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 24 | + steps: |
| 25 | + - name: Send Release Announcement |
| 26 | + uses: sarisia/actions-status-discord@v1 |
| 27 | + with: |
| 28 | + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 29 | + title: "🎉 New Release: ${{ github.event.release.name }}" |
| 30 | + description: | |
| 31 | + **Version:** ${{ github.event.release.tag_name }} |
| 32 | + |
| 33 | + **What's New:** |
| 34 | + ${{ github.event.release.body }} |
| 35 | + |
| 36 | + **Download:** |
| 37 | + • [CLI Releases](https://github.com/acp-protocol/acp-spec/releases) |
| 38 | + • [Installation Guide](https://github.com/acp-protocol/acp-spec/blob/main/cli/README.md#installation) |
| 39 | + |
| 40 | + **Full Changelog:** ${{ github.event.release.html_url }} |
| 41 | + color: 0x4ECDC4 |
| 42 | + username: ACP Bot |
| 43 | + avatar_url: https://github.com/acp-protocol.png |
| 44 | + |
| 45 | + issue-notification: |
| 46 | + name: Issue Notification |
| 47 | + runs-on: ubuntu-latest |
| 48 | + if: github.event_name == 'issues' |
| 49 | + steps: |
| 50 | + - name: Determine Issue Type |
| 51 | + id: issue-type |
| 52 | + run: | |
| 53 | + LABELS="${{ join(github.event.issue.labels.*.name, ' ') }}" |
| 54 | + if echo "$LABELS" | grep -q "bug"; then |
| 55 | + echo "type=bug" >> $GITHUB_OUTPUT |
| 56 | + echo "channel=bug-reports" >> $GITHUB_OUTPUT |
| 57 | + echo "emoji=🐛" >> $GITHUB_OUTPUT |
| 58 | + elif echo "$LABELS" | grep -q "enhancement\|feature"; then |
| 59 | + echo "type=feature" >> $GITHUB_OUTPUT |
| 60 | + echo "channel=feature-requests" >> $GITHUB_OUTPUT |
| 61 | + echo "emoji=✨" >> $GITHUB_OUTPUT |
| 62 | + else |
| 63 | + echo "type=general" >> $GITHUB_OUTPUT |
| 64 | + echo "channel=general" >> $GITHUB_OUTPUT |
| 65 | + echo "emoji=📝" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Send Issue Notification |
| 69 | + if: github.event.action == 'opened' |
| 70 | + uses: sarisia/actions-status-discord@v1 |
| 71 | + with: |
| 72 | + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 73 | + title: "${{ steps.issue-type.outputs.emoji }} New Issue: ${{ github.event.issue.title }}" |
| 74 | + description: | |
| 75 | + **Type:** ${{ steps.issue-type.outputs.type }} |
| 76 | + **Author:** ${{ github.event.issue.user.login }} |
| 77 | + |
| 78 | + ${{ github.event.issue.body }} |
| 79 | + |
| 80 | + **View Issue:** ${{ github.event.issue.html_url }} |
| 81 | + |
| 82 | + Discuss in: <#${{ steps.issue-type.outputs.channel }}> |
| 83 | + color: 0xFF6B6B |
| 84 | + username: ACP Bot |
| 85 | + |
| 86 | + - name: Send Issue Closed Notification |
| 87 | + if: github.event.action == 'closed' |
| 88 | + uses: sarisia/actions-status-discord@v1 |
| 89 | + with: |
| 90 | + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 91 | + title: "✅ Issue Closed: ${{ github.event.issue.title }}" |
| 92 | + description: | |
| 93 | + Issue #${{ github.event.issue.number }} has been closed. |
| 94 | + |
| 95 | + **View Issue:** ${{ github.event.issue.html_url }} |
| 96 | + color: 0x96CEB4 |
| 97 | + username: ACP Bot |
| 98 | + |
| 99 | + pr-notification: |
| 100 | + name: Pull Request Notification |
| 101 | + runs-on: ubuntu-latest |
| 102 | + if: github.event_name == 'pull_request' |
| 103 | + steps: |
| 104 | + - name: Send PR Notification |
| 105 | + if: github.event.action == 'opened' |
| 106 | + uses: sarisia/actions-status-discord@v1 |
| 107 | + with: |
| 108 | + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 109 | + title: "🔧 New Pull Request: ${{ github.event.pull_request.title }}" |
| 110 | + description: | |
| 111 | + **Author:** ${{ github.event.pull_request.user.login }} |
| 112 | + **Branch:** ${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }} |
| 113 | + |
| 114 | + ${{ github.event.pull_request.body }} |
| 115 | + |
| 116 | + **View PR:** ${{ github.event.pull_request.html_url }} |
| 117 | + |
| 118 | + Discuss in: <#contributing> |
| 119 | + color: 0x45B7D1 |
| 120 | + username: ACP Bot |
| 121 | + |
| 122 | + - name: Send PR Merged Notification |
| 123 | + if: github.event.action == 'closed' && github.event.pull_request.merged == true |
| 124 | + uses: sarisia/actions-status-discord@v1 |
| 125 | + with: |
| 126 | + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 127 | + title: "✅ Pull Request Merged: ${{ github.event.pull_request.title }}" |
| 128 | + description: | |
| 129 | + PR #${{ github.event.pull_request.number }} by ${{ github.event.pull_request.user.login }} has been merged! |
| 130 | + |
| 131 | + **Changes:** ${{ github.event.pull_request.additions }} additions, ${{ github.event.pull_request.deletions }} deletions |
| 132 | + |
| 133 | + **View PR:** ${{ github.event.pull_request.html_url }} |
| 134 | + |
| 135 | + Thank you for contributing! 🎉 |
| 136 | + color: 0x96CEB4 |
| 137 | + username: ACP Bot |
| 138 | + |
| 139 | + contributor-recognition: |
| 140 | + name: Contributor Recognition |
| 141 | + runs-on: ubuntu-latest |
| 142 | + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true |
| 143 | + steps: |
| 144 | + - name: Check if First Contribution |
| 145 | + id: first-contribution |
| 146 | + uses: actions/github-script@v7 |
| 147 | + with: |
| 148 | + script: | |
| 149 | + const { data: contributions } = await github.rest.repos.listContributors({ |
| 150 | + owner: context.repo.owner, |
| 151 | + repo: context.repo.repo, |
| 152 | + }); |
| 153 | + |
| 154 | + const contributor = contributions.find(c => c.login === '${{ github.event.pull_request.user.login }}'); |
| 155 | + const isFirst = contributor && contributor.contributions === 1; |
| 156 | + |
| 157 | + core.setOutput('is_first', isFirst); |
| 158 | +
|
| 159 | + - name: Send First Contribution Recognition |
| 160 | + if: steps.first-contribution.outputs.is_first == 'true' |
| 161 | + uses: sarisia/actions-status-discord@v1 |
| 162 | + with: |
| 163 | + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 164 | + title: "🌟 Welcome New Contributor: ${{ github.event.pull_request.user.login }}" |
| 165 | + description: | |
| 166 | + ${{ github.event.pull_request.user.login }} made their first contribution to ACP! |
| 167 | + |
| 168 | + **PR:** ${{ github.event.pull_request.title }} |
| 169 | + **View:** ${{ github.event.pull_request.html_url }} |
| 170 | + |
| 171 | + Thank you for contributing to the ACP project! 🎉 |
| 172 | + color: 0xFFEAA7 |
| 173 | + username: ACP Bot |
| 174 | + |
| 175 | + changelog-update: |
| 176 | + name: Changelog Update Notification |
| 177 | + runs-on: ubuntu-latest |
| 178 | + if: github.event_name == 'push' && contains(github.event.head_commit.message, 'changelog') || contains(github.event.head_commit.message, 'CHANGELOG') |
| 179 | + steps: |
| 180 | + - name: Send Changelog Update |
| 181 | + uses: sarisia/actions-status-discord@v1 |
| 182 | + with: |
| 183 | + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 184 | + title: "📝 Changelog Updated" |
| 185 | + description: | |
| 186 | + The changelog has been updated with new changes. |
| 187 | + |
| 188 | + **Commit:** ${{ github.event.head_commit.message }} |
| 189 | + **View:** ${{ github.event.head_commit.url }} |
| 190 | + color: 0xDDA0DD |
| 191 | + username: ACP Bot |
| 192 | + |
0 commit comments