Skip to content

Commit

Permalink
wip: Add support for sending email on instance created, started or st…
Browse files Browse the repository at this point in the history
…opped

App password created using https://myaccount.google.com/apppasswords
  • Loading branch information
jcfr committed Apr 18, 2024
1 parent 98f35fa commit efa9e04
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ body:
description: Briefly describe how you will be using the instance.
validations:
required: false

- type: input
attributes:
label: Email
description: Email to use for notifications.
validations:
required: true
52 changes: 52 additions & 0 deletions .github/workflows/control-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ jobs:
env:
NUMBER: ${{ github.event.issue.number }}
- name: Extract email
id: extract
run: |
email=$(
echo ${{ toJSON(steps.parse.outputs.data) }} |
jq -r ".email.text"
)
echo "email=$email" >> $GITHUB_OUTPUT
- name: Send mail
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde # v3.12.0
with:
server_address: smtp.gmail.com
server_port: 465
secure: true
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
from: MorphoCloudPortal
to: ${{ steps.extract.outputs.email }}
subject:
"[MorphoCloudPortal] Instance ${{ github.event.issue.number }}
started"
body: Instance ${{ github.event.issue.number }} started

stop:
runs-on: self-hosted
if:
Expand All @@ -30,3 +54,31 @@ jobs:
echo Stopping instance associated with issue $NUMBER
env:
NUMBER: ${{ github.event.issue.number }}
- name: Issue Forms Body Parser
id: parse
uses: zentered/[email protected]

- name: Extract email
id: extract
run: |
email=$(
echo ${{ toJSON(steps.parse.outputs.data) }} |
jq -r ".email.text"
)
echo "email=$email" >> $GITHUB_OUTPUT
- name: Send mail
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde # v3.12.0
with:
server_address: smtp.gmail.com
server_port: 465
secure: true
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
from: MorphoCloudPortal
to: ${{ steps.extract.outputs.email }}
subject:
"[MorphoCloudPortal] Instance ${{ github.event.issue.number }}
stopped"
body: Instance ${{ github.event.issue.number }} stopped
28 changes: 28 additions & 0 deletions .github/workflows/create-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,31 @@ jobs:
echo Creating instance associated with issue $NUMBER
env:
NUMBER: ${{ github.event.issue.number }}
- name: Issue Forms Body Parser
id: parse
uses: zentered/[email protected]

- name: Extract email
id: extract
run: |
email=$(
echo ${{ toJSON(steps.parse.outputs.data) }} |
jq -r ".email.text"
)
echo "email=$email" >> $GITHUB_OUTPUT
- name: Send mail
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde # v3.12.0
with:
server_address: smtp.gmail.com
server_port: 465
secure: true
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
from: MorphoCloudPortal
to: ${{ steps.extract.outputs.email }}
subject:
"[MorphoCloudPortal] Instance ${{ github.event.issue.number }}
created"
body: Instance ${{ github.event.issue.number }} created

0 comments on commit efa9e04

Please sign in to comment.