diff --git a/.github/workflows/make-monthly-pr.yml b/.github/workflows/make-monthly-pr.yml new file mode 100644 index 00000000..c4716862 --- /dev/null +++ b/.github/workflows/make-monthly-pr.yml @@ -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