Skip to content

Commit 256246e

Browse files
authored
[CI] Add check:expired and fix:expired (#5808)
1 parent d33b26e commit 256246e

13 files changed

+27
-99
lines changed

.github/workflows/pr-actions.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: |
3232
PR_ACTION=$(echo $COMMENT | grep -oP '/fix:\K[-_0-9a-z]+')
3333
echo "Action is $PR_ACTION"
34-
ACTION_NAMES="all|dict|filenames|format|htmltest-config|i18n|markdown|refcache|submodules?|text"
34+
ACTION_NAMES="all|dict|expired|filenames|format|htmltest-config|i18n|markdown|refcache|submodules?|text"
3535
if [[ ! "$PR_ACTION" =~ ^($ACTION_NAMES)$ ]]; then
3636
echo "Invalid action name: $PR_ACTION"
3737
echo "Action name should be one of: $ACTION_NAMES"

content/en/announcements/2024-community-awards.md

-9
This file was deleted.

content/en/announcements/eBPF.md

-8
This file was deleted.

content/en/announcements/kubecon-china.md

-9
This file was deleted.

content/en/announcements/kubecon-na-2024.md

-9
This file was deleted.

content/en/announcements/otel-community-day.md

-10
This file was deleted.

content/en/announcements/otel-localized.md

-9
This file was deleted.

content/ja/announcements/otel-community-day.md

-12
This file was deleted.

content/ja/announcements/otel-localized.md

-10
This file was deleted.

content/pt/announcements/otel-localized.md

-10
This file was deleted.

content/zh/announcements/otel-community-day.md

-12
This file was deleted.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"build:production": "npm run _hugo -- --minify",
4646
"build": "npm run _build",
4747
"cd:public": "cd public &&",
48+
"check:expired": "find content -name '*.md' | xargs ./scripts/list-expired.pl",
4849
"check:filenames": "test -z \"$(npm run -s _ls-bad-filenames)\" || npm run -s _filename-error",
4950
"check:format": "npm run _check:format && npm run _check:format:ja+zh || (echo '[help] Run: npm run fix:format'; exit 1)",
5051
"check:i18n": "scripts/check-i18n.sh",
@@ -64,6 +65,7 @@
6465
"diff:fail": "npm run _diff:check || (echo; echo 'ERROR: the files above have changed. Locally rerun `npm run test-and-fix` and commit changes'; echo; exit 1)",
6566
"fix:all": "npm run all -- $(npm -s run _list:fix:*)",
6667
"fix:dict": "find content/{en,es,fr,pt} layouts -name \"*.md\" -print0 | xargs -0 scripts/normalize-cspell-front-matter.pl",
68+
"fix:expired": "npm run -s check:expired -- -q | xargs -r -I {} sh -c 'echo \"Deleting expired file: {}\" && rm {}'",
6769
"fix:filenames": "npm run _rename-to-kebab-case",
6870
"fix:format": "npm run format",
6971
"fix:htmltest-config": "scripts/htmltest-config.sh",

scripts/list-expired.pl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/perl -w
2+
3+
use Getopt::Long;
4+
5+
my $quiet = 0;
6+
GetOptions('q' => \$quiet);
7+
8+
BEGIN {
9+
my $num_days_in_past = 2;
10+
my $seconds_in_a_day = 86400; # Number of seconds in a day
11+
my $year_offset = 1900; # Offset for year in gmtime
12+
my $month_offset = 1; # Offset for month in gmtime
13+
14+
my @gmtime = gmtime(time - $num_days_in_past * $seconds_in_a_day);
15+
our $cut_off_date = sprintf "%04d-%02d-%02d", $gmtime[5] + $year_offset, $gmtime[4] + $month_offset, $gmtime[3];
16+
}
17+
18+
while (<>) {
19+
if (/^expiryDate:\s*([^#\n]+)/ && $1 le $cut_off_date) {
20+
print "$ARGV";
21+
printf "\t expired on %s", $1 unless $quiet;
22+
print "\n";
23+
}
24+
}

0 commit comments

Comments
 (0)