Skip to content

Commit 4cf08d3

Browse files
committed
2 parents d69a6f8 + e280fdb commit 4cf08d3

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

.github/workflows/commit-log.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Commit Log to Discord
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
7+
jobs:
8+
discord:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Extract commit info
12+
id: info
13+
run: |
14+
echo "sha_short=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
15+
echo "msg_first=$(echo '${{ github.event.head_commit.message }}' | head -n1 | sed 's/"/\\"/g')" >> $GITHUB_OUTPUT
16+
echo "repo=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT
17+
echo "ref=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
18+
19+
- name: Send embed to Discord
20+
run: |
21+
JSON=$(cat <<EOF
22+
{
23+
"embeds": [{
24+
"title": "[${{ steps.info.outputs.repo }}] ${{ steps.info.outputs.msg_first }}",
25+
"url": "https://github.com/${{ github.repository }}/commit/${{ github.sha }}",
26+
"description": "Commit \`${{ steps.info.outputs.sha_short }}\` on \`${{ steps.info.outputs.ref }}\`",
27+
"color": 5814783,
28+
"footer": {
29+
"text": "${{ steps.info.outputs.repo }}"
30+
}
31+
}]
32+
}
33+
EOF)
34+
curl -s -H "Content-Type: application/json" \
35+
-d "$JSON" \
36+
${{ secrets.DISCORD_WEBHOOK_GITHUB }}

0 commit comments

Comments
 (0)