# #
#   @type               github workflow
#   @desc               pings the developer
#   @author             Aetherinox
#   @url                https://github.com/Aetherinox
# #

name: "⚙️ Ping › Developer"
run-name: "⚙️ Ping › Developer"

# #
#   triggers
# #

on:
    issue_comment:
        types: [created]

# #
#   environment variables
# #

env:
    BOT_NAME_1:           AdminServ
    BOT_NAME_2:           AdminServX
    BOT_NAME_3:           EuropaServ
    BOT_NAME_DEPENDABOT:  dependabot[bot]

# #
#   jobs
#
#   env not available for job.if
# #

jobs:
    deploy:
        runs-on: ubuntu-latest
        if: |
            contains(github.event.comment.body, '/ping')
        steps:

            # #
            #   Job > Complete > Get publish timestamp
            # #

            - name: "🕛 Get Timestamp"
              id: task_complete_timestamp_get
              run: |
                echo "NOW=$(date +'%m-%d-%Y %H:%M:%S')" >> $GITHUB_ENV

            # #
            #   Add Label to accepted PR
            #
            #   port 465
            #       server_port: 465
            #       secure: true
            #       ignore_cert: false
            #
            #   port 587
            #       server_port: 587
            #       secure: false
            # #

            - name: Send mail
              uses: dawidd6/action-send-mail@v4
              with:
                    server_address: ${{secrets.EMAIL_SMTP}}
                    server_port: 465
                    secure: true
                    username: ${{secrets.EMAIL_FROM}}
                    password: ${{secrets.EMAIL_KEY}}
                    subject: "Github: Ping notification from ${{ github.repository }}"
                    to: ${{secrets.EMAIL_TO}}
                    from: ${{secrets.EMAIL_FROM}}
                    html_body: |
                        <!DOCTYPE html>
                        <html>
                        <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                        <title>Title</title>

                        <style>
                        body {
                        background: url('https://images.unsplash.com/photo-1541422348463-9bc715520974?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8M3x8ZGFyayUyMG1vdW50YWlufGVufDB8fDB8fHww');
                        font-size:9pt;
                        margin:0;
                        padding:0;
                        }
                        .background-overlay {
                        background-color: #1111119f;
                        }
                        .background-header {
                        background: url('https://process.fs.teachablecdn.com/ADNupMnWyR7kCWRvm76Laz/resize=width:705/https://cdn.filestackcontent.com/MipxnobQRRS5h7raz9aM');
                        background-size: cover;
                        background-size: 100%;
                        background-color:#1b1b1b;
                        padding:5px;
                        height:100px;
                        }
                        </style>
                        </head>

                        <body>
                        <div class="background-overlay">
                        <center>
                        <div class="background-header">
                        <a href="https://github.com/${{ github.repository }}"><img style="height:80px;padding-top:10px;" src="https://cdn0.iconfinder.com/data/icons/shift-logotypes/32/Github-512.png"></a>
                        </div>
                        </center>

                        <div style="font-size:9pt;padding: 20px;color:#FFF;">
                        <h3><span style="font-size:9pt;color:#cc6613;">[Github]</span> <span style="font-size:9pt;color:#FFF;">Dear ${{github.repository_owner}},</span></h3>
                        <p style="font-size:9pt;color:#FFF;"><br />You have received a ping notification from <a href="https://github.com/${{ github.repository }}">${{ github.repository }}</a> by <a href="https://github.com/${{ github.event.comment.user.login }}">${{ github.event.comment.user.login }}</a>.</p>
                        <br>
                        <br>
                        <center>
                        <table cellspacing="0" cellpadding="0" width="40%" class="center">
                        <tbody>
                        <tr>
                        <td
                        style="font-size:9pt;background-color:#8a2138;color:#FFF;padding:6px;padding-left:10px;"><b>Repository</b></td>
                        <td style="font-size:9pt;padding-left:5px;color:#b3b3b3;background-color:#1b1b1b;padding-left:10px;">${{ github.repository }}</td>
                        </tr>
                        <tr>
                        <td
                        style="font-size:9pt;background-color:#8a2138;color:#FFF;padding:6px;padding-left:10px;"><b>Date</b></td>
                        <td style="font-size:9pt;padding-left:5px;color:#b3b3b3;background-color:#0f0f0f;padding-left:10px;">${{ env.NOW }}</td>
                        </tr>
                        <tr>
                        <td
                        style="font-size:9pt;background-color:#8a2138;color:#FFF;padding:6px;padding-left:10px;"><b>Commenter</b></td>
                        <td style="font-size:9pt;padding-left:5px;color:#b3b3b3;background-color:#1b1b1b;padding-left:10px;">${{ github.event.comment.user.login }}</td>
                        </tr>
                        <tr>
                        <td
                        style="font-size:9pt;background-color:#8a2138;color:#FFF;padding:6px;padding-left:10px;"><b>Issue #</b></td>
                        <td style="font-size:9pt;padding-left:5px;color:#b3b3b3;background-color:#0f0f0f;padding-left:10px;">${{ github.event.issue.number }}</td>
                        </tr>
                        <tr>
                        <td
                        style="font-size:9pt;background-color:#8a2138;color:#FFF;padding:6px;padding-left:10px;"><b>Action</b></td>
                        <td style="font-size:9pt;padding-left:5px;color:#b3b3b3;background-color:#1b1b1b;padding-left:10px;">Notification</td>
                        </tr>
                        </tbody>
                        </table>
                        </center>

                        <br><br>

                        <center>
                        <div style="font-family:Consolas;">

                        <textarea readonly=true style="font-size:9pt;width:60%;background-color:#363636;color:#FFF;padding:15px;border:1px solid #5a5a5a;" id="w3review" name="w3review" rows="20" cols="100">
                        ${{ github.event.comment.body }}
                        </textarea>

                        </div>
                        </center>

                        <p>&nbsp;</p>
                        <p style="color:#FFF;"><br /> ~ Github
                        </p>
                        </div>

                        <br /><br />

                        <div style="background-color:#1b1b1b;padding:5px;line-height:70px;height:70px;text-align:center;">
                        <span style="color:#FFF;font-size:8pt;">Copyright &copy; 2024 - Betelgeuse</span>
                        </div>
                        </div>
                        </body>
                        </html>
                    ignore_cert: true
                    convert_markdown: true
                    priority: normal
