File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 }}
You can’t perform that action at this time.
0 commit comments