-
Notifications
You must be signed in to change notification settings - Fork 59
35 lines (30 loc) · 1.17 KB
/
newsletter.yml
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
name: "Publish newsletter"
on:
schedule:
- cron: "0 16 * * 5"
jobs:
newsletter:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Trigger Netlify build (to ensure remote images are hosted)
run: curl -X POST -d {} ${{ secrets.NETLIFY_NIGHTLY_WEBHOOK }}
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "0.96.0"
extended: true
- name: Build site
run: hugo
- name: Send newsletter
run: |
if [ -f public/newsletter/$(date +%F)-*/email.html ]; then
SUBJECT=$(grep -oE "<title>.*</title>" public/newsletter/$(date +%F)-*/email.html | sed "s/<title>//" | sed "s/<\/title>//")
cat public/newsletter/$(date +%F)-*/email.html | curl -s --user 'api:${{ secrets.MAILGUN_API_KEY }}' \
https://api.eu.mailgun.net/v3/tomlinson.email/messages \
-F from='Jacob Tomlinson (newsletter) <jacob+newsletter@tomlinson.email>' \
-F to=newsletter@tomlinson.email \
-F subject="$SUBJECT" \
-F html='<-'
fi