From f43be6f40b1ad5987d694943f0658387168829dd Mon Sep 17 00:00:00 2001 From: Bartosz Nikitiuk Date: Thu, 20 Nov 2025 21:28:45 +0100 Subject: [PATCH] Kolejne poprawki: - brak nadpisywania przez action profilowego webhooka - wszytko teraz jest w jednym action - webhook wysyla powiadomienie dopiero jak obraz dockera sie zbuduje --- .github/workflows/discord-notify.yml | 57 ---------------------------- .github/workflows/docker-publish.yml | 47 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/discord-notify.yml diff --git a/.github/workflows/discord-notify.yml b/.github/workflows/discord-notify.yml deleted file mode 100644 index 73c2677..0000000 --- a/.github/workflows/discord-notify.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Powiadomienie Discord - -on: - push: - branches: - - main - -jobs: - notify: - runs-on: ubuntu-latest - steps: - - name: Wyślij powiadomienie na Discord - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }} - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - COMMIT_URL: ${{ github.event.head_commit.url }} - REPO_NAME: ${{ github.repository }} - run: | - if [ -z "$DISCORD_WEBHOOK" ]; then - echo "Błąd: Sekret DISCORD_WEBHOOK nie jest ustawiony." - exit 1 - fi - - # Budowanie bezpiecznego JSON-a za pomocą jq - PAYLOAD=$(jq -n \ - --arg author "$COMMIT_AUTHOR" \ - --arg msg "$COMMIT_MESSAGE" \ - --arg url "$COMMIT_URL" \ - --arg repo "$REPO_NAME" \ - '{ - username: "GitHub Actions", - avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", - embeds: [{ - title: ("Nowy commit w " + $repo + " 🚀"), - url: $url, - color: 5814783, - fields: [ - { - name: "Autor", - value: $author, - inline: true - }, - { - name: "Wiadomość", - value: $msg - } - ], - footer: { - text: "GitHub Actions" - }, - timestamp: now | todate - }] - }') - - # Wysłanie żądania do Discorda - echo "$PAYLOAD" | curl -H "Content-Type: application/json" -d @- "$DISCORD_WEBHOOK" diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d9b1654..6687f52 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -129,3 +129,50 @@ jobs: - name: Inspect image run: | docker buildx imagetools inspect ${{ env.DOCKERHUB_IMAGE }}:${{ steps.meta.outputs.version }} + + - name: Wyślij powiadomienie na Discord + if: success() + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + COMMIT_URL: ${{ github.event.head_commit.url }} + REPO_NAME: ${{ github.repository }} + run: | + if [ -z "$DISCORD_WEBHOOK" ]; then + echo "Błąd: Sekret DISCORD_WEBHOOK nie jest ustawiony." + exit 0 + fi + + # Budowanie bezpiecznego JSON-a za pomocą jq + PAYLOAD=$(jq -n \ + --arg author "$COMMIT_AUTHOR" \ + --arg msg "$COMMIT_MESSAGE" \ + --arg url "$COMMIT_URL" \ + --arg repo "$REPO_NAME" \ + '{ + username: "Glance nowe szponty", + embeds: [{ + title: ("Nowy commit w " + $repo + " 🚀"), + url: $url, + color: 5814783, + fields: [ + { + name: "Autor", + value: $author, + inline: true + }, + { + name: "Wiadomość", + value: $msg + } + ], + footer: { + text: "GitHub Actions" + }, + timestamp: now | todate + }] + }') + + # Wysłanie żądania do Discorda + echo "$PAYLOAD" | curl -H "Content-Type: application/json" -d @- "$DISCORD_WEBHOOK"