Kolejne poprawki:

- brak nadpisywania przez action profilowego webhooka
- wszytko teraz jest w jednym action
- webhook wysyla powiadomienie dopiero jak obraz dockera sie zbuduje
pull/878/head
Bartosz Nikitiuk 2025-11-20 21:28:45 +07:00
parent 8706a1728d
commit f43be6f40b
No known key found for this signature in database
GPG Key ID: 725EADAB8CDD0DB1
2 changed files with 47 additions and 57 deletions

@ -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"

@ -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"