diff --git a/.github/workflows/discord-notify.yml b/.github/workflows/discord-notify.yml new file mode 100644 index 0000000..1a5ecdd --- /dev/null +++ b/.github/workflows/discord-notify.yml @@ -0,0 +1,39 @@ +name: Discord Commit Notification + +on: + push: + branches: + - '**' + +jobs: + notify: + runs-on: ubuntu-latest + + steps: + - name: Send Discord notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + run: | + COMMIT_SHA="${{ github.sha }}" + SHORT_SHA="${COMMIT_SHA:0:7}" + COMMIT_MESSAGE="${{ github.event.head_commit.message }}" + AUTHOR="${{ github.event.head_commit.author.name }}" + BRANCH="${{ github.ref_name }}" + REPO="${{ github.repository }}" + COMMIT_URL="https://github.com/${REPO}/commit/${COMMIT_SHA}" + + curl -s -X POST "$DISCORD_WEBHOOK" \ + -H "Content-Type: application/json" \ + -d "{ + \"embeds\": [{ + \"title\": \"New Commit in \`${REPO}\`\", + \"url\": \"${COMMIT_URL}\", + \"color\": 5814783, + \"fields\": [ + { \"name\": \"Author\", \"value\": \"${AUTHOR}\", \"inline\": true }, + { \"name\": \"Branch\", \"value\": \"\`${BRANCH}\`\", \"inline\": true }, + { \"name\": \"Commit\", \"value\": \"[\`${SHORT_SHA}\`](${COMMIT_URL})\", \"inline\": true }, + { \"name\": \"Message\", \"value\": \"${COMMIT_MESSAGE}\" } + ] + }] + }"