Skip to content

Commit 2626ddf

Browse files
authored
Create main.yml
1 parent acfa33a commit 2626ddf

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Notify Discord on Push
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
notify-discord:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Get last commit info
14+
id: commit
15+
run: |
16+
echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
17+
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
18+
echo "full_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
19+
20+
- name: Send Discord Notification
21+
env:
22+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
23+
run: |
24+
curl -H "Content-Type: application/json" \
25+
-X POST \
26+
-d "{\"content\": \"[\`${{ steps.commit.outputs.sha }}\`](https://github.com/${{ github.repository }}/commit/${{ steps.commit.outputs.full_sha }}) [Commit] **${{ steps.commit.outputs.msg }}** by @${{ github.actor }}\"}" \
27+
"$DISCORD_WEBHOOK_URL"

0 commit comments

Comments
 (0)