Skip to content

Commit cb73446

Browse files
Update generate-newsletter.yml
1 parent e96a835 commit cb73446

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

.github/workflows/generate-newsletter.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,38 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v3
1515

16-
- name: Print raw issue body
17-
run: |
18-
echo "--------- GITHUB.EVENT.ISSUE.BODY ---------"
19-
echo "${{ github.event.issue.body }}"
20-
echo "-------------------------------------------"
21-
2216
- name: Extract values from issue body
2317
id: vars
2418
run: |
2519
body="${{ github.event.issue.body }}"
26-
27-
echo "RAW ISSUE BODY START"
20+
21+
echo "--------- RAW ISSUE BODY ---------"
2822
echo "$body"
29-
echo "RAW ISSUE BODY END"
30-
31-
# Use awk to find the lines after each heading
23+
echo "----------------------------------"
24+
25+
# Parse the body using reliable pattern matching
3226
month=$(echo "$body" | awk '/### Newsletter Month/ {getline; print}' | xargs)
3327
year=$(echo "$body" | awk '/### Newsletter Year/ {getline; print}' | xargs)
34-
28+
3529
if [ -z "$month" ] || [ -z "$year" ]; then
3630
echo "❌ Could not extract month or year from issue body."
3731
exit 1
3832
fi
39-
33+
34+
# Convert month name to number
4035
month_num=$(date -d "$month 1" '+%m')
4136
date="${year}-${month_num}-01"
4237
branch="feature/newsletter-${year}-${month_num}"
4338
filename="_posts/${date}-newsletter.md"
44-
39+
40+
echo "✅ Parsed values:"
41+
echo " Month: $month"
42+
echo " Year: $year"
43+
echo " Month Num: $month_num"
44+
echo " Date: $date"
45+
echo " Branch: $branch"
46+
echo " Filename: $filename"
47+
4548
echo "month=$month" >> $GITHUB_OUTPUT
4649
echo "month_num=$month_num" >> $GITHUB_OUTPUT
4750
echo "year=$year" >> $GITHUB_OUTPUT
@@ -73,4 +76,9 @@ jobs:
7376
env:
7477
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7578
run: |
76-
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"
79+
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 }}\`.
80+
81+
You can now:
82+
1. Open the branch in VS Code using GitFlow (\`feature/newsletter-${{ steps.vars.outputs.year }}-${{ steps.vars.outputs.month_num }}\`)
83+
2. Edit and review the draft
84+
3. Open a PR into \`develop\` when ready"

0 commit comments

Comments
 (0)