create a reusable workflow that send email

This commit is contained in:
SaillantNicolas 2023-02-22 14:49:02 +01:00 committed by GitHub
parent 5604425c5e
commit 10d1521bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 0 deletions

31
.github/workflows/send_email.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Send Email
on:
workflow_call:
inputs:
message:
description: 'Message to send'
required: true
type: string
email:
description: 'Email address to send to'
required: true
type: string
secrets:
private_key:
required: true
user:
required: true
jobs:
send_email:
runs-on: ubuntu-latest
steps:
- name: install ssh keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.private_key }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ vars.CGAL_SEND_EMAIL_SSH_HOST }} > ~/.ssh/known_hosts
- name: send email via ssh
run: |
echo "${{ inputs.message }}" | ssh ${{ secrets.user }}@${{ vars.CGAL_SEND_EMAIL_SSH_HOST }} "/sbin/sendmail -t ${{ inputs.email }}"