2023-01-20 17:41:11 +08:00
|
|
|
name: Send email
|
|
|
|
|
|
|
|
on:
|
|
|
|
schedule:
|
2023-03-27 12:40:21 +08:00
|
|
|
- cron: '30 3 * * *'
|
2023-01-22 17:14:55 +08:00
|
|
|
|
|
|
|
# If uncommented run on every push to every branch for easier debugging
|
|
|
|
# on: push
|
2023-01-20 17:41:11 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2023-03-29 12:30:38 +08:00
|
|
|
timeout-minutes: 2
|
2023-01-22 17:14:55 +08:00
|
|
|
permissions: read-all
|
2023-01-20 17:41:11 +08:00
|
|
|
|
|
|
|
steps:
|
2023-10-19 23:58:26 +08:00
|
|
|
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
2023-01-22 17:14:55 +08:00
|
|
|
|
2023-01-20 17:41:11 +08:00
|
|
|
- name: Use Node.js
|
|
|
|
uses: actions/setup-node@v3
|
2023-01-20 18:43:56 +08:00
|
|
|
with:
|
2023-01-22 19:21:50 +08:00
|
|
|
node-version: 18
|
2023-01-20 18:43:56 +08:00
|
|
|
cache: 'npm'
|
2023-01-20 17:41:11 +08:00
|
|
|
|
2023-01-22 17:14:55 +08:00
|
|
|
- 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 }}
|
|
|
|
|
2023-01-20 17:41:11 +08:00
|
|
|
- run: npm ci
|
2023-01-20 18:10:19 +08:00
|
|
|
|
2023-01-22 17:14:55 +08:00
|
|
|
- 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
|
2023-01-20 17:41:11 +08:00
|
|
|
id: check_email
|
|
|
|
uses: andstor/file-existence-action@v2.0.0
|
|
|
|
with:
|
2023-01-20 17:42:23 +08:00
|
|
|
files: 'dist/email.html'
|
2023-01-20 17:41:11 +08:00
|
|
|
|
2023-01-20 18:01:06 +08:00
|
|
|
- name: Send email
|
2023-01-20 17:41:11 +08:00
|
|
|
if: steps.check_email.outputs.files_exists == 'true'
|
2023-09-27 22:42:13 +08:00
|
|
|
uses: dawidd6/action-send-mail@v3.9.0
|
2023-01-20 18:01:06 +08:00
|
|
|
with:
|
2023-01-23 22:07:19 +08:00
|
|
|
server_address: ${{ vars.SMTP_SERVER }}
|
|
|
|
server_port: ${{ vars.SMTP_PORT }}
|
2023-01-20 18:01:06 +08:00
|
|
|
|
2023-01-23 22:07:19 +08:00
|
|
|
username: ${{ secrets.SMTP_USERNAME }}
|
|
|
|
password: ${{ secrets.SMTP_PASSWORD }}
|
2023-01-20 18:01:06 +08:00
|
|
|
|
|
|
|
subject: RSS to Email
|
2023-01-22 17:14:55 +08:00
|
|
|
to: ${{ secrets.MAIL_TO }}
|
2023-01-23 22:07:19 +08:00
|
|
|
from: ${{ secrets.SMTP_USERNAME }}
|
2023-01-20 18:01:06 +08:00
|
|
|
|
|
|
|
html_body: file://dist/email.html
|