-
Notifications
You must be signed in to change notification settings - Fork 3
61 lines (46 loc) · 1.6 KB
/
Copy pathmain.yml
File metadata and controls
61 lines (46 loc) · 1.6 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Automated Admin Commit Notification
on:
push:
branches: ["master"]
permissions:
contents: read
jobs:
notify-admin:
runs-on: ubuntu-latest
environment:
name: main
steps:
- name: Checkout Code with Full History
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Generate Commit Message and Diff Data
id: git_details
run: |
echo "COMMIT_MSG=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
echo "COMMIT_AUTHOR=$(git log -1 --pretty=format:'%an')" >> $GITHUB_ENV
echo "GIT_DIFF<<EOF" >> $GITHUB_ENV
git diff HEAD~1 HEAD | head -n 100 >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Send Email Notification to Admin
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
subject: "Commit Notification: Push by ${{ env.COMMIT_AUTHOR }}"
to: eamon112009@gmail.com
from: GitHub Automation Engine
body: |
Hello Admin,
A new commit has been successfully pushed to the repository.
Commit Message:
"${{ env.COMMIT_MSG }}"
Pushed By:
${{ env.COMMIT_AUTHOR }}
Code Changes Summary (Diff Preview):
--------------------------------------------------
${{ env.GIT_DIFF }}
--------------------------------------------------
View full logs directly inside the GitHub Actions pipeline interface.