Improve outdated tutorials check
- Extract summary building in a script that can be run locally
- Include the date of the tutorials in the summary table
- Add the year to the created issue title
- Test the workflow when files are changed in a pull_request
If you run outdated-tutorials-summary.sh on the first day of the month using cron:
https://github.com/hetzneronline/community-content/blob/37f2d5629243834648170589ffc920d6300dc20a/.github/workflows/outdated-tutorials.yml#L4-L5
then tutorials written in the previous year, but not on the first day of the month will not be present in the table. You will need to wait two years to review them.
This condition will be false, because their timestamps will be bigger: https://github.com/hetzneronline/community-content/blob/37f2d5629243834648170589ffc920d6300dc20a/hack/outdated-tutorials-summary.sh#L43
To reproduce, replace:
-
last_year_timestamp=$(date +'%s' -d '1 year ago')withlast_year_timestamp=$(date +'%s' -d '2023-12-01 00:00:00') -
last_year_month=$(date +'%m' -d '1 year ago')withlast_year_month=12
This tutorial will not be present.
@jooola
I made small changes. See here: https://github.com/wpdevelopment11/community-content/blob/stale/hack/outdated-tutorials-summary.sh
I dropped timestamps, I think they are not needed here. Script should work correctly now.
Now yq commands are executed only when there're really needed. This reduces the execution time on my machine from 5,2s to 2s.
Why you placed a script to the hack directory?
While looking at your changes I found a bug in the old script 😀.
Try to execute the following command, it prints nothing:
head -n 20 tutorials/cloudflare-website-protect/01.en.md | awk '/^---$/{f=!f;next}f'
If you add \r to the awk command it prints the front matter:
head -n 20 tutorials/cloudflare-website-protect/01.en.md | awk '/^---\r$/{f=!f;next}f'
Basically the previous script was broken for tutorials that used Windows style line endings.
Superseded by #1235