forked from bdevos/rss-to-email
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (47 loc) · 1.88 KB
/
send-email.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Send email
on:
schedule:
- cron: '30 9 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions: read-all
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Last successful run
id: last_success
run: echo "LAST_SUCCESS=$(gh api -XGET repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/workflows/send-email.yaml/runs --jq '.workflow_runs[0].run_started_at' -F status=success -F per_page=1)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm ci
- name: Create email
run: npm run email actionUrl=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} lastSuccess=${{ steps.last_success.outputs.LAST_SUCCESS }}
- name: Check email exists
id: check_email
run: |
if [ -f dist/email.html ]; then
echo "files_exists=true" >> $GITHUB_OUTPUT
echo "### New update email :inbox_tray:" >> $GITHUB_STEP_SUMMARY
else
echo "### No updates since last run :zzz:" >> $GITHUB_STEP_SUMMARY
fi
- name: Send email
if: steps.check_email.outputs.files_exists == 'true'
uses: dawidd6/[email protected]
with:
server_address: ${{ vars.SMTP_SERVER }}
server_port: ${{ vars.SMTP_PORT }}
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
bcc: ${{ secrets.MAIL_TO }}
from: HaoBIT
subject: Bulletin Issues Transferred
in_reply_to: <bulletin-issues-transferred/Capchdo/[email protected]>
html_body: file://dist/email.html