Skip to content

Prepare newsletter script ci #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/prepare_newsletter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 }}
8 changes: 4 additions & 4 deletions newsletter-template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
+++
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
+++

<!-- no toc -->

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

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.
Expand All @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions scripts/prepare_newsletter.sh
Original file line number Diff line number Diff line change
@@ -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