File size: 2,078 Bytes
f9916f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9cb30fa
 
 
 
 
 
 
 
 
 
0eebee2
9cb30fa
 
 
 
 
 
 
 
 
 
4911ad8
f9916f7
 
0828746
9cb30fa
f9916f7
9cb30fa
 
 
 
 
 
f9916f7
 
1dd7058
 
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
name: Email Notification

on:
  push:
    branches:
      - main

jobs:
  notify:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Get Commit Details
        id: commit_details
        run: |
          AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
          AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
          COMMIT_HASH=$(git log -1 --pretty=format:'%h')
          COMMIT_DATE=$(git log -1 --pretty=format:'%cd' --date=short)
          COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')
          BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
          REPO_NAME=$(basename $(git rev-parse --show-toplevel))
          COMMIT_URL="https://github.com/RahulChhatbar/TextGenPro/commit/${COMMIT_HASH}"

          echo "AUTHOR_NAME=${AUTHOR_NAME}" >> $GITHUB_ENV
          echo "AUTHOR_EMAIL=${AUTHOR_EMAIL}" >> $GITHUB_ENV
          echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
          echo "COMMIT_DATE=${COMMIT_DATE}" >> $GITHUB_ENV
          echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
          echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
          echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
          echo "COMMIT_URL=${COMMIT_URL}" >> $GITHUB_ENV

      - name: Send Email Notification to primary email
        uses: cinotify/github-action@v1.6.0
        with:
          to: ${{ secrets.EMAIL_TO_1 }},${{ secrets.EMAIL_TO_2 }}
          subject: 'Push Notification: ${{ env.REPO_NAME }} - ${{ env.BRANCH_NAME }}'
          body: |
            <p>A push has been made to the branch ${{ env.BRANCH_NAME }} in repository ${{ env.REPO_NAME }}!</p>
            <p>Author: ${{ env.AUTHOR_NAME }} &lt;${{ env.AUTHOR_EMAIL }}&gt;<br>
            Commit Hash: ${{ env.COMMIT_HASH }}<br>
            Commit Date: ${{ env.COMMIT_DATE }}<br>
            Commit Message: ${{ env.COMMIT_MESSAGE }}<br>
            Commit URL: ${{ env.COMMIT_URL }}</p>
          type: 'text/html'
        env:
          EMAIL_TO_1: ${{ secrets.EMAIL_TO_1 }}
          EMAIL_TO_2: ${{ secrets.EMAIL_TO_2 }}