File tree 2 files changed +38
-11
lines changed
2 files changed +38
-11
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ if [[ -z " ${NEWSLETTER_MONTH} " ]]; then
6
+ echo " NEWSLETTER_MONTH is not set. Exiting..."
7
+ exit 1
8
+ fi
9
+
10
+ if [[ -z " ${NEWSLETTER_YEAR} " ]]; then
11
+ echo " NEWSLETTER_YEAR is not set. Exiting..."
12
+ exit 1
13
+ fi
14
+
15
+ if [[ -z " ${NEWSLETTER_DEADLINE} " ]]; then
16
+ echo " NEWSLETTER_DEADLINE is not set. Exiting..."
17
+ exit 1
18
+ fi
19
+
20
+ if [[ -z " ${NEWSLETTER_COUNTER} " ]]; then
21
+ echo " NEWSLETTER_COUNTER is not set. Exiting..."
22
+ exit 1
23
+ fi
24
+
25
+ cp newsletter-template.md index.md
26
+ sed -i " s/{{\s*NEWSLETTER_MONTH\s*}}/${NEWSLETTER_MONTH} /g" index.md
27
+ sed -i " s/{{\s*NEWSLETTER_YEAR\s*}}/${NEWSLETTER_YEAR} /g" index.md
28
+ sed -i " s/{{\s*NEWSLETTER_DEADLINE\s*}}/${NEWSLETTER_DEADLINE} /g" index.md
29
+ sed -i " s/{{\s*NEWSLETTER_COUNTER\s*}}/${NEWSLETTER_COUNTER} /g" index.md
30
+ # Create a dir in content/news with the counter with 3 digits as name
31
+ destination=" content/news/$( printf " %03d" ${NEWSLETTER_COUNTER} ) "
32
+ mkdir -p $destination
33
+ mv index.md $destination /index.md
34
+ git status
Original file line number Diff line number Diff line change 13
13
runs-on : ubuntu-latest
14
14
steps :
15
15
- uses : actions/checkout@v3
16
+ with :
17
+ ref : source
16
18
- name : Set environment variables
17
19
run : |
18
20
echo "NEWSLETTER_MONTH=$(date +'%B')" >> $GITHUB_ENV
@@ -21,21 +23,12 @@ jobs:
21
23
# take the amount of months since feb 2024 and add 50
22
24
echo "NEWSLETTER_COUNTER=$(( ( ( $(date +'%Y') - 2024 ) * 12 + $(date +'%m') - 2 ) + 50 ))" >> $GITHUB_ENV
23
25
- name : Create newsletter scaffold
24
- run : |
25
- cp newsletter-template.md index.md
26
- sed -i "s/{{\s*NEWSLETTER_MONTH\s*}}/${{ env.NEWSLETTER_MONTH }}/g" index.md
27
- sed -i "s/{{\s*NEWSLETTER_YEAR\s*}}/${{ env.NEWSLETTER_YEAR }}/g" index.md
28
- sed -i "s/{{\s*NEWSLETTER_DEADLINE\s*}}/${{ env.NEWSLETTER_DEADLINE }}/g" index.md
29
- sed -i "s/{{\s*NEWSLETTER_COUNTER\s*}}/${{ env.NEWSLETTER_COUNTER }}/g" index.md
30
- # Create a dir in content/news with the counter with 3 digits as name
31
- destination="content/news/$(printf "%03d" ${{ env.NEWSLETTER_COUNTER }})"
32
- mkdir -p $destination
33
- mv index.md $destination/index.md
34
- git status
26
+ run : ./.github/create_newsletter_scaffold.sh
35
27
- name : Commit and push changes
36
28
uses : EndBug/add-and-commit@v9
37
29
with :
38
30
message : " Create newsletter N${{ env.NEWSLETTER_COUNTER }} for ${{ env.NEWSLETTER_MONTH }} ${{ env.NEWSLETTER_YEAR }}"
31
+ push : " origin HEAD:source"
39
32
- name : Create tracking issue
40
33
uses : JasonEtco/create-an-issue@v2
41
34
env :
You can’t perform that action at this time.
0 commit comments