Skip to content

Commit 991406c

Browse files
Merge branch 'main' into develop
2 parents 9240942 + a94444a commit 991406c

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

.github/workflows/generate-newsletter.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,41 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v3
1515

16-
- name: Extract values from issue body
16+
- name: Print raw issue body
17+
run: |
18+
echo "--------- GITHUB.EVENT.ISSUE.BODY ---------"
19+
echo "${{ github.event.issue.body }}"
20+
echo "-------------------------------------------"
21+
22+
- name: Extract values from issue title
1723
id: vars
1824
run: |
19-
month=$(echo "${{ github.event.issue.body }}" | grep -i "Newsletter Month" -A 1 | tail -n 1 | xargs)
20-
year=$(echo "${{ github.event.issue.body }}" | grep -i "Newsletter Year" -A 1 | tail -n 1 | xargs)
21-
# Convert month name to MM
25+
title="${{ github.event.issue.title }}"
26+
27+
# Extract month and year using awk
28+
month=$(echo "$title" | awk -F': ' '{print $2}' | awk '{print $1}')
29+
year=$(echo "$title" | awk -F': ' '{print $2}' | awk '{print $2}')
30+
31+
if [ -z "$month" ] || [ -z "$year" ]; then
32+
echo "❌ Could not extract month or year from title."
33+
echo "Title was: $title"
34+
exit 1
35+
fi
36+
2237
month_num=$(date -d "$month 1" '+%m')
23-
date="${year}-${month_num}-01"
38+
date="${year}-${month_num}"
2439
branch="feature/newsletter-${year}-${month_num}"
25-
filename="_posts/${date}-newsletter.md"
26-
40+
filename="_posts/newsletters/${date}-newsletter.md"
41+
42+
echo "✅ Parsed values:"
43+
echo " Title: $title"
44+
echo " Month: $month"
45+
echo " Year: $year"
46+
echo " Month Num: $month_num"
47+
echo " Date: $date"
48+
echo " Branch: $branch"
49+
echo " Filename: $filename"
50+
2751
echo "month=$month" >> $GITHUB_OUTPUT
2852
echo "month_num=$month_num" >> $GITHUB_OUTPUT
2953
echo "year=$year" >> $GITHUB_OUTPUT
@@ -56,3 +80,4 @@ jobs:
5680
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5781
run: |
5882
gh issue comment ${{ github.event.issue.number }} --body "Draft file created for **${{ steps.vars.outputs.month }} ${{ steps.vars.outputs.year }}** at \`${{ steps.vars.outputs.filename }}\` in branch \`${{ steps.vars.outputs.branch }}\`.\n\nYou can now:\n1. Open the branch in VS Code using GitFlow (\`feature/newsletter-${{ steps.vars.outputs.year }}-${{ steps.vars.outputs.month_num }}\`)\n2. Edit and review the draft\n3. Open a PR into \`develop\` when ready"
83+

0 commit comments

Comments
 (0)