From 3e837e20c62876816e89991f0e154145c7b98ed2 Mon Sep 17 00:00:00 2001 From: Juro Oravec Date: Fri, 3 Oct 2025 14:31:12 +0200 Subject: [PATCH] ci: fix discord integration (#1430) --- .github/workflows/discussion-discord.yml | 61 +++++++++++------------ .github/workflows/issue-discord.yml | 11 +++-- .github/workflows/pr-discord.yml | 62 ++++++++++++------------ 3 files changed, 68 insertions(+), 66 deletions(-) diff --git a/.github/workflows/discussion-discord.yml b/.github/workflows/discussion-discord.yml index 0a9af5d7..52cc46f4 100644 --- a/.github/workflows/discussion-discord.yml +++ b/.github/workflows/discussion-discord.yml @@ -1,35 +1,36 @@ name: Notify Discord on new discussions on: - discussion: - types: [created] + discussion: + types: [created] jobs: - notify: - runs-on: ubuntu-latest - steps: - - name: Post to Discord (development channel) - env: - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_DEVELOPMENT }} - run: | - payload=$(jq -n \ - --arg title "${{ github.event.discussion.title }}" \ - --arg url "${{ github.event.discussion.html_url }}" \ - --arg user "${{ github.event.discussion.user.login }}" \ - --arg repo "${{ github.repository }}" \ - --arg number "#${{ github.event.discussion.number }}" \ - '{ - "username": "GitHub Discussions", - "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", - "embeds": [ - { - "title": "New discussion: \($number) \($title)", - "url": \($url), - "color": 16776960, - "author": {"name": \($user)}, - "footer": {"text": \($repo)}, - "timestamp": "${{ github.event.discussion.created_at }}" - } - ] - }') - curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat + notify: + runs-on: ubuntu-latest + steps: + - name: Post to Discord (development channel) + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_DEVELOPMENT }} + run: | + payload=$(jq -n \ + --arg title "${{ github.event.discussion.title }}" \ + --arg url "${{ github.event.discussion.html_url }}" \ + --arg user "${{ github.event.discussion.user.login }}" \ + --arg repo "${{ github.repository }}" \ + --arg number "#${{ github.event.discussion.number }}" \ + --arg timestamp "${{ github.event.discussion.created_at }}" \ + '{ + "username": "GitHub Discussions", + "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", + "embeds": [ + { + "title": ("New discussion: " + $number + " " + $title), + "url": $url, + "color": 16776960, + "author": {"name": $user}, + "footer": {"text": $repo}, + "timestamp": $timestamp + } + ] + }') + curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat diff --git a/.github/workflows/issue-discord.yml b/.github/workflows/issue-discord.yml index 6a637e6d..6d422a83 100644 --- a/.github/workflows/issue-discord.yml +++ b/.github/workflows/issue-discord.yml @@ -18,17 +18,18 @@ jobs: --arg user "${{ github.event.issue.user.login }}" \ --arg repo "${{ github.repository }}" \ --arg number "#${{ github.event.issue.number }}" \ + --arg timestamp "${{ github.event.issue.created_at }}" \ '{ "username": "GitHub Issues", "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", "embeds": [ { - "title": "New issue: \($number) \($title)", - "url": \($url), + "title": ("New issue: " + $number + " " + $title), + "url": $url, "color": 3447003, - "author": {"name": \($user)}, - "footer": {"text": \($repo)}, - "timestamp": "${{ github.event.issue.created_at }}" + "author": {"name": $user}, + "footer": {"text": $repo}, + "timestamp": $timestamp } ] }') diff --git a/.github/workflows/pr-discord.yml b/.github/workflows/pr-discord.yml index 379e5a9d..8f394748 100644 --- a/.github/workflows/pr-discord.yml +++ b/.github/workflows/pr-discord.yml @@ -1,36 +1,36 @@ name: Notify Discord on new PRs on: - pull_request: - types: [opened] + pull_request: + types: [opened] jobs: - notify: - runs-on: ubuntu-latest - steps: - - name: Post to Discord (development channel) - env: - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_DEVELOPMENT }} - run: | - payload=$(jq -n \ - --arg title "${{ github.event.pull_request.title }}" \ - --arg url "${{ github.event.pull_request.html_url }}" \ - --arg user "${{ github.event.pull_request.user.login }}" \ - --arg repo "${{ github.repository }}" \ - --arg number "#${{ github.event.pull_request.number }}" \ - '{ - "username": "GitHub Pull Requests", - "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", - "embeds": [ - { - "title": "New pull request: \($number) \($title)", - "url": \($url), - "color": 3066993, - "author": {"name": \($user)}, - "footer": {"text": \($repo)}, - "timestamp": "${{ github.event.pull_request.created_at }}" - } - ] - }') - curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat - + notify: + runs-on: ubuntu-latest + steps: + - name: Post to Discord (development channel) + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_DEVELOPMENT }} + run: | + payload=$(jq -n \ + --arg title "${{ github.event.pull_request.title }}" \ + --arg url "${{ github.event.pull_request.html_url }}" \ + --arg user "${{ github.event.pull_request.user.login }}" \ + --arg repo "${{ github.repository }}" \ + --arg number "#${{ github.event.pull_request.number }}" \ + --arg timestamp "${{ github.event.pull_request.created_at }}" \ + '{ + "username": "GitHub Pull Requests", + "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", + "embeds": [ + { + "title": ("New pull request: " + $number + " " + $title), + "url": $url, + "color": 3066993, + "author": {"name": $user}, + "footer": {"text": $repo}, + "timestamp": $timestamp + } + ] + }') + curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat