From 3fa633addc0401b6d1b0466bee74dc9c70fbfc4f Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Mon, 16 Oct 2023 12:29:15 +0200 Subject: [PATCH 1/3] script to help preparing new newswletters --- newsletter-template.md | 8 ++++---- scripts/prepare_newsletter.sh | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 scripts/prepare_newsletter.sh diff --git a/newsletter-template.md b/newsletter-template.md index 831ecd123..491d9de16 100644 --- a/newsletter-template.md +++ b/newsletter-template.md @@ -1,7 +1,7 @@ +++ -title = "This Month in Rust GameDev #{TODO} - {TODO} {TODO}" +title = "This Month in Rust GameDev #{TODO_id} - {TODO_month} {TODO_day}" transparent = true -date = TODO +date = {TODO_date} draft = true +++ @@ -9,7 +9,7 @@ draft = true -Welcome to the {TODO}th issue of the Rust GameDev Workgroup's +Welcome to the {TODO_id}th issue of the Rust GameDev Workgroup's monthly newsletter. [Rust] is a systems language pursuing the trifecta: safety, concurrency, and speed. @@ -35,8 +35,8 @@ Feel free to send PRs about your own projects! - [Learning Material Updates](#learning-material-updates) - [Tooling Updates](#tooling-updates) - [Library Updates](#library-updates) -- [Other News](#other-news) - [Popular Workgroup Issues in Github](#popular-workgroup-issues-in-github) +- [Other News](#other-news) - [Meeting Minutes](#meeting-minutes) - [Discussions](#discussions) - [Requests for Contribution](#requests-for-contribution) diff --git a/scripts/prepare_newsletter.sh b/scripts/prepare_newsletter.sh new file mode 100644 index 000000000..6653d1a9b --- /dev/null +++ b/scripts/prepare_newsletter.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# This scripts parses existing news, and copies the newsletter template +# alongside the others, with its incremented id number. +# This script also replaces the TODOs related to the news id number. + +read -r -d '\n' -a news <<< `find content/news/ -type d -printf "%f\n"` + +last_news=`echo ${news[-1]} | sed -r s/0//` +echo $last_news +news_to_create_simple=$((last_news+1)) +news_to_create=`printf "%#03s" $news_to_create_simple` + +read -e -p "Do you want to create issue $news_to_create? (y/n): " choice + +[[ "$choice" != [Yy]* ]] && exit + +echo "accepted" + +new_file="content/news/$news_to_create/index.md" + +mkdir -p content/news/$news_to_create && cp -r newsletter-template.md $new_file + +sed -i 's/{TODO_id}/'$news_to_create_simple'/g' $new_file \ No newline at end of file From 6dca493d59116ad2c17763681e31f0ce32321f71 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Fri, 17 Nov 2023 17:36:48 +0100 Subject: [PATCH 2/3] chore: ci to trigger the script for a new newsletter --- .github/workflows/prepare_newsletter.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/prepare_newsletter.yml diff --git a/.github/workflows/prepare_newsletter.yml b/.github/workflows/prepare_newsletter.yml new file mode 100644 index 000000000..3447ad3da --- /dev/null +++ b/.github/workflows/prepare_newsletter.yml @@ -0,0 +1,22 @@ +name: Prepare a new newsletter + +on: + workflow_dispatch: + +jobs: + prepare_new_newsletter: + runs-on: ubuntu-latest + env: + # https://github.com/crazy-max/ghaction-github-pages/issues/1#issuecomment-623202206 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - run: ./zola --version + - name: copy template and adapt dates and ids. + run: echo y | ./scripts/prepare_newsletter.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: create pull request + run: gh pr create -B source -H new_newsletter --title 'Prepare new newsletter' --body 'Created by Github action' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f6c2db38cef30a585f314e6fdc02f44443246aa9 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Fri, 17 Nov 2023 17:45:40 +0100 Subject: [PATCH 3/3] fix? --- .github/workflows/prepare_newsletter.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/prepare_newsletter.yml b/.github/workflows/prepare_newsletter.yml index 3447ad3da..4cd23c1c3 100644 --- a/.github/workflows/prepare_newsletter.yml +++ b/.github/workflows/prepare_newsletter.yml @@ -1,7 +1,6 @@ name: Prepare a new newsletter -on: - workflow_dispatch: +on: workflow_dispatch jobs: prepare_new_newsletter: