Skip to content

Commit d642ea7

Browse files
committed
Incorporate feedback
1 parent 8f0064e commit d642ea7

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

.github/create_newsletter_scaffold.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

.github/workflows/create-newsletter.yaml

+4-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16+
with:
17+
ref: source
1618
- name: Set environment variables
1719
run: |
1820
echo "NEWSLETTER_MONTH=$(date +'%B')" >> $GITHUB_ENV
@@ -21,21 +23,12 @@ jobs:
2123
# take the amount of months since feb 2024 and add 50
2224
echo "NEWSLETTER_COUNTER=$(( ( ( $(date +'%Y') - 2024 ) * 12 + $(date +'%m') - 2 ) + 50 ))" >> $GITHUB_ENV
2325
- 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
3527
- name: Commit and push changes
3628
uses: EndBug/add-and-commit@v9
3729
with:
3830
message: "Create newsletter N${{ env.NEWSLETTER_COUNTER }} for ${{ env.NEWSLETTER_MONTH }} ${{ env.NEWSLETTER_YEAR }}"
31+
push: "origin HEAD:source"
3932
- name: Create tracking issue
4033
uses: JasonEtco/create-an-issue@v2
4134
env:

0 commit comments

Comments
 (0)