Skip to content

Commit 5118b6b

Browse files
camelidJoshua Nelson
authored and
Joshua Nelson
committed
Implement date-checker
This tool looks for HTML comments like `<!-- date: 2021-01 -->` in each Markdown source file and compiles a list of dates that are older than six months. It then opens an issue with that list, with checkboxes for each file and date. Note that it will only open an issue if there was at least one date older than six months; it does nothing if the list is empty. This tool is automatically run monthly in a GitHub Actions workflow. I have tested the tool on a private repo and confirmed that it works.
1 parent bd008cc commit 5118b6b

File tree

5 files changed

+442
-1
lines changed

5 files changed

+442
-1
lines changed

Diff for: .github/workflows/date-check.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Date-Check
2+
3+
on:
4+
schedule:
5+
# Run at noon UTC every 1st of the month
6+
- cron: '00 12 01 * *'
7+
8+
# Allow manually starting the workflow
9+
workflow_dispatch:
10+
11+
jobs:
12+
date-check:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v2
18+
19+
- name: Run `date-check`
20+
working-directory: ci/date-check
21+
run: |
22+
cargo run -- ../../src/ > ../../date-check-output.txt
23+
24+
- name: Open issue
25+
uses: actions/github-script@v3
26+
with:
27+
github-token: ${{secrets.GITHUB_TOKEN}}
28+
script: |
29+
const fs = require('fs');
30+
31+
const rawText = fs.readFileSync('date-check-output.txt', { encoding: 'utf8' });
32+
const title = rawText.split('\n')[0];
33+
if (title != 'empty') {
34+
const body = rawText.split('\n').slice(1).join('\n');
35+
github.issues.create({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
title,
39+
body,
40+
});
41+
console.log('Opened issue.');
42+
} else {
43+
console.log('No dates to triage.');
44+
}

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
book
22

3-
# prevent accidentally changes
3+
# prevent accidental changes
44
book.toml
5+
6+
ci/date-check/target/

Diff for: ci/date-check/Cargo.lock

+147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ci/date-check/Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "date-check"
3+
version = "0.1.0"
4+
authors = ["Camelid <camelidcamel@gmail.com>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
glob = "0.3"
11+
regex = "1"
12+
chrono = "0.4"

0 commit comments

Comments
 (0)