瀏覽代碼

chore(notify-discord): refactor Discord notification workflow to enhance message formatting and include release details

This update improves the Discord notification by adding structured release information, including the release title, description, and author details, while removing unnecessary steps and simplifying the output format.
Mathias 1 月之前
父節點
當前提交
dca05f6dda
共有 1 個文件被更改,包括 24 次插入36 次删除
  1. 24 36
      .github/workflows/notify-discord.yml

+ 24 - 36
.github/workflows/notify-discord.yml

@@ -8,55 +8,43 @@ jobs:
   Discord:
     runs-on: ubuntu-latest
     name: Discord Notifier
-    #if: "contains(github.event.head_commit.message, '[skip ci]')"
     steps:
       - uses: actions/checkout@v3
         with:
-          fetch-depth: 0  # OR "2" -> To retrieve the preceding commit.
-      - name: Get changed files
+          fetch-depth: 0
+      - name: Get changed files since last release
         id: changed-files
         uses: tj-actions/changed-files@v34
         with:
-          separator: "----------------------"
-      - name: List all changed files
-        run: |
-          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
-            echo "$file was changed"
-          done
-      - uses: benjlevesque/short-sha@v2.1
-        id: short-sha
-        with:
-          length: 7
-      - run: echo $SHA
-        env: 
-          SHA: ${{ steps.short-sha.outputs.sha }}
-      - run: echo $SHA
-        env: 
-          SHA: ${{ env.SHA }}
+          base_sha: ${{ github.event.release.target_commitish }}
+          separator: "\n• "
       - name: Discord notification
         env:
           DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
           DISCORD_AVATAR: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'
-          DISCORD_EMBEDS: '[    { 
-          "author": {  "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },
-          "url": "https://github.com/${{github.repository}}/commit/${{github.sha}}",
+          DISCORD_EMBEDS: '[{
+          "title": "🚀 New Release: ${{ github.event.release.tag_name }}",
+          "description": "${{ github.event.release.name }}\n\n${{ github.event.release.body }}",
+          "url": "${{ github.event.release.html_url }}",
+          "color": 5763719,
+          "thumbnail": {
+            "url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
+          },
           "fields": [
-          { "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },
-          { "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/tree/${{github.ref_name}})", "inline": true },
-          { "name": "Event", "value": "${{github.event_name}}", "inline": true },
-          { "name": "Job", "value": "${{github.job}}", "inline": true },
-          { "name": "Commit Message", "value": "[${{ env.SHA }}](https://github.com/${{github.repository}}/commit/${{github.sha}}) - `${{github.event.head_commit.message}}`" },
-          { "name": "Changed Files", "value": "${{ steps.changed-files.outputs.all_changed_files }}" },
-          { "name": "Author", "value": "[${{github.event.head_commit.author.name}}](https://github.com/${{github.actor}})" }
+            { "name": "📦 Version", "value": "`${{ github.event.release.tag_name }}`", "inline": true },
+            { "name": "👤 Released by", "value": "[${{ github.event.release.author.login }}](${{ github.event.release.author.html_url }})", "inline": true },
+            { "name": "🌟 Type", "value": "${{ github.event.release.prerelease && 'Pre-release' || 'Stable' }}", "inline": true },
+            { "name": "📁 Repository", "value": "[${{ github.event.repository.name }}](${{ github.event.repository.html_url }})", "inline": true },
+            { "name": "🔗 Download", "value": "[Release Page](${{ github.event.release.html_url }})", "inline": true },
+            { "name": "📝 Files Changed", "value": "• ${{ steps.changed-files.outputs.all_changed_files }}", "inline": false }
           ],
-          "color":1127128,
-          "timestamp": "${{github.event.head_commit.timestamp}}",
-          "footer":{"text": "${{github.event.head_commit.timestamp}}"}
-          }    ]'
+          "timestamp": "${{ github.event.release.published_at }}",
+          "footer": {
+            "text": "Workout Cool • Release",
+            "icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
+          }
+          }]'
         uses: Ilshidur/action-discord@master
-      - name: echo
-        run: | 
-          echo ${{github.event_name}}
 
 # https://stackoverflow.com/a/68068674/19395252
 # https://birdie0.github.io/discord-webhooks-guide/structure/embeds.html