Repository navigation
81 lines (70 loc) · 2.75 KB
/
Copy pathupdate-stats.yml
File metadata and controls
81 lines (70 loc) · 2.75 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
name: Update GitHub Statistics
on:
schedule:
# Run weekly on Sundays at 00:00 UTC
- cron: '0 0 * * 0'
workflow_dispatch:
# Allow manual trigger
permissions:
contents: write
issues: write
jobs:
update-stats:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.VWAD_REBUILD }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install requests
- name: Run update script
run: |
python .github/workflows/scripts/update_stats.py
- name: Check for changes
id: git-check
run: |
if [ -n "$(git status --short _data/collection.json _data/archived_repos.json 2>/dev/null)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push if changed
if: steps.git-check.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add _data/collection.json _data/archived_repos.json
git commit -m "Update GitHub statistics [automated]"
git push
- name: No changes detected
if: steps.git-check.outputs.changed != 'true'
run: |
echo "No changes to collection.json or archived repos list"
- name: Create issue for archived repositories
if: success() && hashFiles('archived_repos.json') != ''
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const fs = require('fs');
if (!fs.existsSync('archived_repos.json')) {
console.log('No archived repositories');
return;
}
const data = JSON.parse(fs.readFileSync('archived_repos.json', 'utf8'));
if (!data.archived_repos || data.archived_repos.length === 0) {
console.log('No archived repositories');
return;
}
const issueBody = fs.readFileSync('archived-repos-issue-body.md', 'utf8');
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `📦 Archived repositories in directory (${data.run_date})`,
body: issueBody,
labels: ['archived-repo']
});
console.log(`Created issue for ${data.archived_repos.length} archived repository(ies)`);