Skip to content

Commit c99f200

Browse files
chore(ci): notifier
1 parent bac0360 commit c99f200

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/notifier.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 🔔 Discord Notification on PR Merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
notify:
11+
if: github.event.pull_request.merged == true
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get Files Diff (Créés et Modifiés dans docs/**/*.md)
21+
id: diff
22+
uses: dorny/paths-filter@v3
23+
with:
24+
filters: |
25+
added:
26+
- added: "docs/**/*.md"
27+
modified:
28+
- modified: "docs/**/*.md"
29+
30+
- name: Prepare Discord Payload
31+
id: payload
32+
run: |
33+
ADDED_FILES="${{ steps.diff.outputs.added_files }}"
34+
MODIFIED_FILES="${{ steps.diff.outputs.modified_files }}"
35+
36+
if [ -z "$ADDED_FILES" ] && [ -z "$MODIFIED_FILES" ]; then
37+
echo "::notice file=notify-discord-on-merge.yml::Aucun fichier docs/**/*.md créé ou modifié, la notification sera ignorée."
38+
exit 0
39+
fi
40+
41+
if [ -z "$ADDED_FILES" ]; then
42+
ADDED_LIST="> *Aucun nouveau fichier de documentation créé.*"
43+
else
44+
ADDED_LIST=$(echo "$ADDED_FILES" | sed 's/ /\n> ➕ /g' | sed 's/^/> ➕ /')
45+
fi
46+
47+
if [ -z "$MODIFIED_FILES" ]; then
48+
MODIFIED_LIST="> *Aucun fichier de documentation modifié.*"
49+
else
50+
# Remplace les espaces par des sauts de ligne + ajouter un préfixe ✍️
51+
MODIFIED_LIST=$(echo "$MODIFIED_FILES" | sed 's/ /\n> ✍️ /g' | sed 's/^/> ✍️ /')
52+
fi
53+
54+
DISCORD_MESSAGE="**🎉 Nouvelles contributions (${{ github.event.pull_request.number }})**"
55+
DISCORD_MESSAGE+="\n\n**Titre :** ${{ github.event.pull_request.title }}"
56+
DISCORD_MESSAGE+="\n**Auteur :** ${{ github.event.pull_request.user.login }}"
57+
DISCORD_MESSAGE+="\n\n---"
58+
DISCORD_MESSAGE+="\n\n**Nouvelles docs:**\n$ADDED_LIST"
59+
DISCORD_MESSAGE+="\n\n**Docs Modifiése:**\n$MODIFIED_LIST"
60+
DISCORD_MESSAGE+="\n\n[Voir la PR](${{ github.event.pull_request.html_url }})"
61+
62+
echo "DISCORD_MESSAGE<<EOF" >> $GITHUB_ENV
63+
echo "$DISCORD_MESSAGE" >> $GITHUB_ENV
64+
echo "EOF" >> $GITHUB_ENV
65+
66+
- name: Send Discord Notification
67+
if: success() && env.DISCORD_MESSAGE != ''
68+
uses: sarisia/actions-discord@v1
69+
with:
70+
webhookId: ${{ secrets.DISCORD_WEBHOOK_ID }}
71+
webhookToken: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
72+
message: ${{ env.DISCORD_MESSAGE }}
73+
color: 00FF00
74+
username: AyLabs Docs Bot

0 commit comments

Comments
 (0)