|
1 |
| -name: Create Newsletter Tracking Issue |
| 1 | +name: Create Newsletter |
2 | 2 | on:
|
3 | 3 | schedule:
|
4 | 4 | # Run on the 5th of every month at 12pm
|
5 | 5 | - cron: "0 12 5 * *"
|
6 | 6 | workflow_dispatch:
|
7 | 7 | inputs: {}
|
8 | 8 | permissions:
|
9 |
| - contents: read |
| 9 | + contents: write |
10 | 10 | issues: write
|
11 | 11 | jobs:
|
12 | 12 | create-newsletter:
|
13 | 13 | runs-on: ubuntu-latest
|
14 | 14 | steps:
|
15 | 15 | - uses: actions/checkout@v3
|
16 |
| - - name: Set newsletter month |
17 |
| - run: echo "NEWSLETTER_MONTH=$(date +'%B')" >> $GITHUB_ENV |
18 |
| - - name: Set newsletter year |
19 |
| - run: echo "NEWSLETTER_YEAR=$(date +'%Y')" >> $GITHUB_ENV |
20 |
| - - name: Set newsletter deadline |
21 |
| - run: echo "NEWSLETTER_DEADLINE=$(date -d' 1 month ' '+%m.%Y')" >> $GITHUB_ENV |
22 |
| - - name: Set newsletter counter |
23 |
| - # take the amount of months since feb 2024 and add 50 |
24 |
| - run: echo "NEWSLETTER_COUNTER=$(( ( ( $(date +'%Y') - 2024 ) * 12 + $(date +'%m') - 2 ) + 50 ))" >> $GITHUB_ENV |
| 16 | + - name: Set environment variables |
| 17 | + run: | |
| 18 | + echo "NEWSLETTER_MONTH=$(date +'%B')" >> $GITHUB_ENV |
| 19 | + echo "NEWSLETTER_YEAR=$(date +'%Y')" >> $GITHUB_ENV |
| 20 | + echo "NEWSLETTER_DEADLINE=$(date -d' 1 month ' '+%m.%Y')" >> $GITHUB_ENV |
| 21 | + # take the amount of months since feb 2024 and add 50 |
| 22 | + echo "NEWSLETTER_COUNTER=$(( ( ( $(date +'%Y') - 2024 ) * 12 + $(date +'%m') - 2 ) + 50 ))" >> $GITHUB_ENV |
| 23 | + - 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 | + mkdir -p content/news/$(printf "%03d" ${{ env.NEWSLETTER_COUNTER }}) |
| 32 | + mv index.md content/news/$(printf "%03d" ${{ env.NEWSLETTER_COUNTER }}) |
| 33 | + - name: Commit and push changes |
| 34 | + uses: EndBug/add-and-commit@v9 |
| 35 | + with: |
| 36 | + message: "Create newsletter N${{ env.NEWSLETTER_COUNTER }} for ${{ env.NEWSLETTER_MONTH }} ${{ env.NEWSLETTER_YEAR }}" |
25 | 37 | - name: Create tracking issue
|
26 | 38 | uses: JasonEtco/create-an-issue@v2
|
27 | 39 | env:
|
28 | 40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
29 | 41 | with:
|
30 |
| - filename: .github/newsletter-template.md |
| 42 | + filename: .github/newsletter-issue-template.md |
31 | 43 |
|
0 commit comments