Skip to content
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

Add a CI script to automate "this month in mathlib" #40

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
46 changes: 46 additions & 0 deletions .github/workflows/make-monthly-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Create 'This month in mathlib' PR"
# This workflow will overwrite any currently open PR for the previous month. Do not run it once a maintainer has started curating the month!

on:
# Allows us to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
generate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
path: blog
- uses: actions/checkout@v3
with:
repository: leanprover-community/mathlib
path: mathlib

- name: Generate the blog post
id: generate
run: |
# get the first day of last month. Hack taken from https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html
date="$(date +%Y-%m-15) -1 month"
date="$(date --date "$date" +%Y-%m-01)"
echo "::set-output name=iso-date::$(date --date="$date" +"%Y-%m")"
slug_date="$(date --date="$date" +"%b-%Y")";
slug_date="${slug_date,,}"; # lowercase

# fetch all the commits from that date onwards
( cd mathlib;
git fetch origin master --shallow-since="$date" );

cd blog
./monthly-blog.sh "$(date --date="$date" +"%Y")" "$(date --date="$date" +"%-m")" ../mathlib > posts/month-in-mathlib-$slug_date.md

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
branch: this-month-in-mathlib/${{ steps.generate.outputs.iso-date }}
title: This month in mathlib (${{ steps.generate.outputs.iso-date }})
commit-message: Auto-generated PR log for ${{ steps.generate.outputs.iso-date }}
body: |
This pull request was generated by a manual trigger of the [`make-monthly-pr`](https://github.com/leanprover-community/blog/actions/workflows/make-monthly-pr.yml) action in this repository.
path: blog