From 10d1521bc63de2fd828203590e8fb0af9e3b6cdb Mon Sep 17 00:00:00 2001 From: SaillantNicolas <97436229+SaillantNicolas@users.noreply.github.com> Date: Wed, 22 Feb 2023 14:49:02 +0100 Subject: [PATCH] create a reusable workflow that send email --- .github/workflows/send_email.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/send_email.yml diff --git a/.github/workflows/send_email.yml b/.github/workflows/send_email.yml new file mode 100644 index 00000000000..d1be170ab2d --- /dev/null +++ b/.github/workflows/send_email.yml @@ -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 }}"