-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (83 loc) · 3.65 KB
/
flake-freshness.yml
File metadata and controls
94 lines (83 loc) · 3.65 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Flake Input Freshness
on:
workflow_dispatch:
schedule:
- cron: "0 8 * * 1"
concurrency:
group: flake-freshness
cancel-in-progress: false
permissions:
issues: write
contents: read
jobs:
check-freshness:
runs-on: ubuntu-latest
steps:
- name: Checkout flake.lock
uses: actions/checkout@v6.0.2
with:
sparse-checkout: flake.lock
sparse-checkout-cone-mode: false
- name: Check input ages
id: freshness
run: |
echo "## 📅 Flake Input Freshness Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
now=$(date +%s)
stale_inputs=""
for input in $(jq -r '.nodes | keys[]' flake.lock | grep -v root); do
last_modified=$(jq -r ".nodes.\"$input\".locked.lastModified // empty" flake.lock)
if [ -n "$last_modified" ]; then
age_days=$(( (now - last_modified) / 86400 ))
if [ "$age_days" -gt 90 ]; then
stale_inputs="${stale_inputs}- **${input}**: ${age_days} days old\n"
echo "⚠️ $input: $age_days days since last update" >> $GITHUB_STEP_SUMMARY
else
echo "✅ $input: $age_days days" >> $GITHUB_STEP_SUMMARY
fi
fi
done
if [ -n "$stale_inputs" ]; then
echo "has_stale=true" >> "$GITHUB_OUTPUT"
{
echo "stale_list<<EOF"
echo -e "$stale_inputs"
echo "EOF"
} >> "$GITHUB_OUTPUT"
else
echo "has_stale=false" >> "$GITHUB_OUTPUT"
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ All inputs updated within the last 90 days" >> $GITHUB_STEP_SUMMARY
fi
- name: Create issue for stale inputs
if: steps.freshness.outputs.has_stale == 'true'
uses: actions/github-script@v8
with:
script: |
const { owner, repo } = context.repo;
const title = '📅 Stale Flake Inputs Detected';
const { data: issues } = await github.rest.issues.listForRepo({
owner, repo,
state: 'open',
labels: 'maintenance',
creator: 'github-actions[bot]',
});
const existing = issues.find(i => i.title === title);
const staleList = `${{ steps.freshness.outputs.stale_list }}`;
const body = [
'## Stale Flake Inputs',
'',
'The following inputs have not been updated in over 90 days:',
'',
staleList,
'',
'Consider running `nix flake update` or updating specific inputs.',
'',
'---',
'*Generated by Flake Freshness Check*',
].join('\n');
if (existing) {
await github.rest.issues.update({ owner, repo, issue_number: existing.number, body });
} else {
await github.rest.issues.create({ owner, repo, title, body, labels: ['maintenance'] });
}