Create a report on Discussion weekly #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create a report on Discussion weekly | |
on: | |
schedule: | |
- cron: 0 0 * * 1 # At 00:00 (UTC-0) on every monday. | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Scan | |
id: report | |
run: > | |
c=$(git rev-list --all --since '1 week ago' --reverse | head -n1 || true) | |
if [ -n ${c:-} ]; then | |
git --no-pager diff --no-color -U0 "$c" HEAD -- '*.md' ':!./_docs' | | |
grep -v -E '^(index|new file mode|deleted file mode|\-\-\-) ' | | |
sed -E -e 's|^diff --git a/(.+) b/.+|```\n\n### \1\n|g' -e 's/^\+\+\+.+/```diff/' | | |
tail +2 | |
fi | |
- name: Create a new GitHub Discussion | |
uses: abirismyname/[email protected] | |
if: ${{ steps.rerport.stdout != '' }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
title: "ADoyle's TIL Weekly ($(date +'%Y-%m-%d'))" | |
body: | | |
What changed in last week: | |
${{steps.rerport.stdout}} | |
``` | |
Details in https://til.adoyle.me/ | |
# https://github.com/marketplace/actions/create-github-discussion#obtaining-the-repository-id-and-category-id | |
repository-id: MDEwOlJlcG9zaXRvcnk1MzAyMzkzNA== | |
category-id: DIC_kwDOAykUvs4CfgjB | |
- name: Print discussion url and id | |
run: | | |
echo discussion-id: ${{steps.create-discussion.outputs.discussion-id}} | |
echo discussion-url: ${{steps.create-discussion.outputs.discussion-url}} |