-
Notifications
You must be signed in to change notification settings - Fork 83
68 lines (60 loc) · 2.29 KB
/
Copy pathrefresh-badges.yml
File metadata and controls
68 lines (60 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Refresh Stars & Last-Updated Badge
# The shields.io badges are live (rendered on every README view), so we don't
# need to rewrite numbers in the file. We do refresh:
# 1. The "Last Updated" date badge in the title block
# 2. Audit any newly-archived projects so we can flag them
#
# Runs monthly + on demand. Opens a PR rather than pushing directly.
on:
schedule:
- cron: "0 5 1 * *" # 05:00 UTC on the 1st of every month
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
refresh:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update Last-Updated badge
run: |
today=$(date -u "+%B%%20%-d%%2C%%202026")
sed -i -E "s|Last%20Updated-[^-]+-blue.svg|Last%20Updated-${today}-blue.svg|" README.md || true
- name: Detect newly-archived listed repos
id: archived
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
mkdir -p artifacts
# Extract owner/repo pairs (skip badge URLs)
grep -oE 'https://github\.com/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+' README.md \
| grep -v "shields.io" \
| sed -E 's|https://github.com/||; s|/$||; s|[).,]+$||' \
| sort -u > artifacts/repos.txt
: > artifacts/archived.md
while read -r repo; do
json=$(gh api "repos/$repo" 2>/dev/null || true)
[ -z "$json" ] && continue
archived=$(jq -r '.archived' <<<"$json")
pushed=$(jq -r '.pushed_at' <<<"$json")
if [ "$archived" = "true" ]; then
if ! grep -qiE "[\`\"]?$repo[\`\"]?.*Archived" README.md; then
echo "- \`$repo\` is now archived (last push: $pushed)" >> artifacts/archived.md
fi
fi
done < artifacts/repos.txt
- name: Open PR if changes
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: chore/auto-refresh
commit-message: "chore: monthly badge refresh + archive scan"
title: "chore: monthly badge refresh + archive scan"
body-path: artifacts/archived.md
labels: |
automation
maintenance
add-paths: |
README.md