-
-
Notifications
You must be signed in to change notification settings - Fork 238
36 lines (33 loc) · 1.21 KB
/
Copy pathcommit-log.yml
File metadata and controls
36 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Commit Log to Discord
on:
push:
branches: [main, master]
jobs:
discord:
runs-on: ubuntu-latest
steps:
- name: Extract commit info
id: info
run: |
echo "sha_short=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
echo "msg_first=$(echo '${{ github.event.head_commit.message }}' | head -n1 | sed 's/"/\\"/g')" >> $GITHUB_OUTPUT
echo "repo=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT
echo "ref=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Send embed to Discord
run: |
JSON=$(cat <<EOF
{
"embeds": [{
"title": "[${{ steps.info.outputs.repo }}] ${{ steps.info.outputs.msg_first }}",
"url": "https://github.com/${{ github.repository }}/commit/${{ github.sha }}",
"description": "Commit \`${{ steps.info.outputs.sha_short }}\` on \`${{ steps.info.outputs.ref }}\`",
"color": 5814783,
"footer": {
"text": "${{ steps.info.outputs.repo }}"
}
}]
}
EOF)
curl -s -H "Content-Type: application/json" \
-d "$JSON" \
${{ secrets.DISCORD_WEBHOOK_GITHUB }}