Skip to content

Commit 4244bde

Browse files
authored
Merge pull request #1 from Vrixyz/prepare_newsletter_script_ci
Prepare newsletter script ci
2 parents 8e0cc6a + f6c2db3 commit 4244bde

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Prepare a new newsletter
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
prepare_new_newsletter:
7+
runs-on: ubuntu-latest
8+
env:
9+
# https://github.com/crazy-max/ghaction-github-pages/issues/1#issuecomment-623202206
10+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11+
steps:
12+
- uses: actions/checkout@v2
13+
- run: ./zola --version
14+
- name: copy template and adapt dates and ids.
15+
run: echo y | ./scripts/prepare_newsletter.sh
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
- name: create pull request
19+
run: gh pr create -B source -H new_newsletter --title 'Prepare new newsletter' --body 'Created by Github action'
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

newsletter-template.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
+++
2-
title = "This Month in Rust GameDev #{TODO} - {TODO} {TODO}"
2+
title = "This Month in Rust GameDev #{TODO_id} - {TODO_month} {TODO_day}"
33
transparent = true
4-
date = TODO
4+
date = {TODO_date}
55
draft = true
66
+++
77

88
<!-- no toc -->
99

1010
<!-- Check the post with markdownlint-->
1111

12-
Welcome to the {TODO}th issue of the Rust GameDev Workgroup's
12+
Welcome to the {TODO_id}th issue of the Rust GameDev Workgroup's
1313
monthly newsletter.
1414
[Rust] is a systems language pursuing the trifecta:
1515
safety, concurrency, and speed.
@@ -35,8 +35,8 @@ Feel free to send PRs about your own projects!
3535
- [Learning Material Updates](#learning-material-updates)
3636
- [Tooling Updates](#tooling-updates)
3737
- [Library Updates](#library-updates)
38-
- [Other News](#other-news)
3938
- [Popular Workgroup Issues in Github](#popular-workgroup-issues-in-github)
39+
- [Other News](#other-news)
4040
- [Meeting Minutes](#meeting-minutes)
4141
- [Discussions](#discussions)
4242
- [Requests for Contribution](#requests-for-contribution)

scripts/prepare_newsletter.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
# This scripts parses existing news, and copies the newsletter template
4+
# alongside the others, with its incremented id number.
5+
# This script also replaces the TODOs related to the news id number.
6+
7+
read -r -d '\n' -a news <<< `find content/news/ -type d -printf "%f\n"`
8+
9+
last_news=`echo ${news[-1]} | sed -r s/0//`
10+
echo $last_news
11+
news_to_create_simple=$((last_news+1))
12+
news_to_create=`printf "%#03s" $news_to_create_simple`
13+
14+
read -e -p "Do you want to create issue $news_to_create? (y/n): " choice
15+
16+
[[ "$choice" != [Yy]* ]] && exit
17+
18+
echo "accepted"
19+
20+
new_file="content/news/$news_to_create/index.md"
21+
22+
mkdir -p content/news/$news_to_create && cp -r newsletter-template.md $new_file
23+
24+
sed -i 's/{TODO_id}/'$news_to_create_simple'/g' $new_file

0 commit comments

Comments
 (0)