|
| 1 | +# ================================================================== |
| 2 | +# SEND EMAIL REUSABLE WORKFLOW (GENERIC) |
| 3 | +# ================================================================== |
| 4 | +name: Send-Email |
| 5 | + |
| 6 | +run-name: ${{ github.actor }} initiated the Send-Email workflow |
| 7 | + |
| 8 | +on: |
| 9 | + |
| 10 | + # triggered manually |
| 11 | + workflow_dispatch: |
| 12 | + # called by other workflows |
| 13 | + workflow_call: |
| 14 | + |
| 15 | + inputs: |
| 16 | + |
| 17 | + server-address: |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + default: 'ragdata.dev' |
| 21 | + |
| 22 | + server-port: |
| 23 | + required: false |
| 24 | + type: number |
| 25 | + default: 587 |
| 26 | + |
| 27 | + secure-flag: |
| 28 | + required: false |
| 29 | + type: boolean |
| 30 | + default: true |
| 31 | + |
| 32 | + mail-subject: |
| 33 | + required: false |
| 34 | + type: string |
| 35 | + default: 'GitHub Actions Job Results' |
| 36 | + |
| 37 | + mail-from: |
| 38 | + required: false |
| 39 | + type: string |
| 40 | + default: '"GitHub Actions" <[email protected]>' |
| 41 | + |
| 42 | + mail-to: |
| 43 | + required: true |
| 44 | + type: string |
| 45 | + default: '' |
| 46 | + |
| 47 | + mail-cc: |
| 48 | + required: false |
| 49 | + type: string |
| 50 | + default: '' |
| 51 | + |
| 52 | + mail-bcc: |
| 53 | + required: false |
| 54 | + type: string |
| 55 | + default: '' |
| 56 | + |
| 57 | + body-text: |
| 58 | + required: false |
| 59 | + type: string |
| 60 | + default: 'Build job of ${{ github.repository }} completed successfully!' |
| 61 | + |
| 62 | + body-html: |
| 63 | + required: false |
| 64 | + type: string |
| 65 | + default: '' |
| 66 | + |
| 67 | + ignore-cert: |
| 68 | + required: false |
| 69 | + type: boolean |
| 70 | + default: true |
| 71 | + |
| 72 | + convert-markdown: |
| 73 | + required: false |
| 74 | + type: boolean |
| 75 | + default: true |
| 76 | + |
| 77 | + attachment-flag: |
| 78 | + required: false |
| 79 | + type: boolean |
| 80 | + default: false |
| 81 | + |
| 82 | + attachments: |
| 83 | + required: false |
| 84 | + type: string |
| 85 | + default: '' |
| 86 | + |
| 87 | + priority: |
| 88 | + required: false |
| 89 | + type: string |
| 90 | + default: low |
| 91 | + |
| 92 | +permissions: |
| 93 | + contents: read |
| 94 | + |
| 95 | +jobs: |
| 96 | + |
| 97 | + send-email: |
| 98 | + name: Send Email |
| 99 | + runs-on: ubuntu-latest |
| 100 | + steps: |
| 101 | + - name: Harden Runner |
| 102 | + uses: step-security/[email protected] |
| 103 | + with: |
| 104 | + egress-policy: audit |
| 105 | + |
| 106 | + - name: Checkout Code |
| 107 | + if: inputs.attachment-flag |
| 108 | + uses: actions/checkout@v3 |
| 109 | + |
| 110 | + - name: Handle Attachments |
| 111 | + if: inputs.attachment-flag |
| 112 | + |
| 113 | + with: |
| 114 | + name: ${{ inputs.attachments }} |
| 115 | + |
| 116 | + - name: Send Email |
| 117 | + |
| 118 | + with: |
| 119 | + server_address: ${{ inputs.server-address }} |
| 120 | + server_port: ${{ inputs.server-port }} |
| 121 | + secure: ${{ inputs.secure-flag }} |
| 122 | + # mail server username is a secret configured at Org level |
| 123 | + username: ${{ secrets.EMAIL_USERNAME }} |
| 124 | + # mail server password is a secret configured at Org level |
| 125 | + password: ${{ secrets.EMAIL_PASSWORD }} |
| 126 | + subject: ${{ inputs.mail-subject }} |
| 127 | + to: ${{ inputs.mail-to }} |
| 128 | + from: ${{ inputs.mail-from }} |
| 129 | + cc: ${{ inputs.mail-cc }} |
| 130 | + bcc: ${{ inputs.mail-bcc }} |
| 131 | + ignore_cert: ${{ inputs.ignore-cert }} |
| 132 | + convert_markdown: ${{ inputs.convert-markdown }} |
| 133 | + attachments: ${{ inputs.attachments }} |
| 134 | + priority: ${{ inputs.priority }} |
0 commit comments