Skip to content

Commit 0426f17

Browse files
committed
wip: Add support for sending email on instance created, started or stopped
App password created using https://myaccount.google.com/apppasswords
1 parent 98f35fa commit 0426f17

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

.github/ISSUE_TEMPLATE/request.yml

+7
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ body:
3333
description: Briefly describe how you will be using the instance.
3434
validations:
3535
required: false
36+
37+
- type: textarea
38+
attributes:
39+
label: Email
40+
description: Email to use for notifications.
41+
validations:
42+
required: true

.github/workflows/control-instance.yml

+52
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ jobs:
2020
env:
2121
NUMBER: ${{ github.event.issue.number }}
2222
23+
- name: Extract email
24+
id: extract
25+
run: |
26+
email=$(
27+
echo ${{ toJSON(steps.parse.outputs.data) }} |
28+
jq -r ".email.text"
29+
)
30+
echo "email=$email" >> $GITHUB_OUTPUT
31+
32+
- name: Send mail
33+
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde # v3.12.0
34+
with:
35+
server_address: smtp.gmail.com
36+
server_port: 465
37+
secure: true
38+
username: ${{secrets.MAIL_USERNAME}}
39+
password: ${{secrets.MAIL_PASSWORD}}
40+
from: MorphoCloudPortal
41+
to: ${{ steps.extract.outputs.email }}
42+
subject:
43+
"[MorphoCloudPortal] Instance ${{ github.event.issue.number }}
44+
started"
45+
body: Instance ${{ github.event.issue.number }} started
46+
2347
stop:
2448
runs-on: self-hosted
2549
if:
@@ -30,3 +54,31 @@ jobs:
3054
echo Stopping instance associated with issue $NUMBER
3155
env:
3256
NUMBER: ${{ github.event.issue.number }}
57+
58+
- name: Issue Forms Body Parser
59+
id: parse
60+
uses: zentered/[email protected]
61+
62+
- name: Extract email
63+
id: extract
64+
run: |
65+
email=$(
66+
echo ${{ toJSON(steps.parse.outputs.data) }} |
67+
jq -r ".email.text"
68+
)
69+
echo "email=$email" >> $GITHUB_OUTPUT
70+
71+
- name: Send mail
72+
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde # v3.12.0
73+
with:
74+
server_address: smtp.gmail.com
75+
server_port: 465
76+
secure: true
77+
username: ${{secrets.MAIL_USERNAME}}
78+
password: ${{secrets.MAIL_PASSWORD}}
79+
from: MorphoCloudPortal
80+
to: ${{ steps.extract.outputs.email }}
81+
subject:
82+
"[MorphoCloudPortal] Instance ${{ github.event.issue.number }}
83+
stopped"
84+
body: Instance ${{ github.event.issue.number }} stopped

.github/workflows/create-instance.yml

+28
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,31 @@ jobs:
1717
echo Creating instance associated with issue $NUMBER
1818
env:
1919
NUMBER: ${{ github.event.issue.number }}
20+
21+
- name: Issue Forms Body Parser
22+
id: parse
23+
uses: zentered/[email protected]
24+
25+
- name: Extract email
26+
id: extract
27+
run: |
28+
email=$(
29+
echo ${{ toJSON(steps.parse.outputs.data) }} |
30+
jq -r ".email.text"
31+
)
32+
echo "email=$email" >> $GITHUB_OUTPUT
33+
34+
- name: Send mail
35+
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde # v3.12.0
36+
with:
37+
server_address: smtp.gmail.com
38+
server_port: 465
39+
secure: true
40+
username: ${{secrets.MAIL_USERNAME}}
41+
password: ${{secrets.MAIL_PASSWORD}}
42+
from: MorphoCloudPortal
43+
to: ${{ steps.extract.outputs.email }}
44+
subject:
45+
"[MorphoCloudPortal] Instance ${{ github.event.issue.number }}
46+
created"
47+
body: Instance ${{ github.event.issue.number }} created

0 commit comments

Comments
 (0)