forked from rust-gamedev/rust-gamedev.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_newsletter_scaffold.sh
executable file
·36 lines (30 loc) · 1.11 KB
/
create_newsletter_scaffold.sh
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
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${NEWSLETTER_MONTH}" ]]; then
echo "NEWSLETTER_MONTH is not set. Exiting..."
exit 1
fi
if [[ -z "${NEWSLETTER_YEAR}" ]]; then
echo "NEWSLETTER_YEAR is not set. Exiting..."
exit 1
fi
if [[ -z "${NEWSLETTER_COUNTER}" ]]; then
echo "NEWSLETTER_COUNTER is not set. Exiting..."
exit 1
fi
# NEWSLETTER_NEXT_MONTH_NUMBER
if [[ -z "${NEWSLETTER_NEXT_MONTH_NUMBER}" ]]; then
echo "NEWSLETTER_NEXT_MONTH_NUMBER is not set. Exiting..."
exit 1
fi
cp .github/newsletter-template.md index.md
sed -i "s/{{\s*NEWSLETTER_MONTH\s*}}/${NEWSLETTER_MONTH}/g" index.md
sed -i "s/{{\s*NEWSLETTER_YEAR\s*}}/${NEWSLETTER_YEAR}/g" index.md
sed -i "s/{{\s*NEWSLETTER_COUNTER\s*}}/${NEWSLETTER_COUNTER}/g" index.md
sed -i "s/{{\s*NEWSLETTER_COUNTER_NEXT\s*}}/$((NEWSLETTER_COUNTER + 1))/g" index.md
sed -i "s/{{\s*NEWSLETTER_NEXT_MONTH_NUMBER\s*}}/${NEWSLETTER_NEXT_MONTH_NUMBER}/g" index.md
# Create a dir in content/news with the counter with 3 digits as name
destination="content/news/$(printf "%03d" ${NEWSLETTER_COUNTER})"
mkdir -p $destination
mv index.md $destination/index.md
git status