-
Notifications
You must be signed in to change notification settings - Fork 7
161 lines (137 loc) · 5.27 KB
/
Copy pathupdate-starred.yml
File metadata and controls
161 lines (137 loc) · 5.27 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Update Starred Repos
on:
# Run daily at 2 AM UTC
schedule:
- cron: '0 2 * * *'
# Run on push to main (for testing)
push:
branches: [main]
paths:
- 'src/**'
- '.github/workflows/update-starred.yml'
# Manual trigger
workflow_dispatch:
inputs:
preferences:
description: 'Categorization preferences (optional)'
required: false
type: string
provider:
description: 'LLM Provider'
required: false
default: 'auto'
type: choice
options:
- auto
- anthropic
- openai
- gemini
force_recategorize:
description: 'Force full recategorization'
required: false
type: boolean
default: false
permissions:
contents: write
env:
PYTHON_VERSION: '3.11'
jobs:
update-starred:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install -e ".[all]"
- name: Restore cached data
uses: actions/cache@v4
with:
path: data/
key: starred-data-${{ github.repository_owner }}-${{ hashFiles('data/*.json') }}
restore-keys: |
starred-data-${{ github.repository_owner }}-
- name: Fetch starred repositories
env:
GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
GH_USERNAME: ${{ github.repository_owner }}
run: |
starred fetch --with-readme --output data/starred_cache.json
- name: Check for changes
id: check-changes
run: |
if [ -f "data/starred_cache.json" ] && [ -f "data/previous_cache.json" ]; then
NEW_COUNT=$(jq length data/starred_cache.json)
OLD_COUNT=$(jq length data/previous_cache.json)
if [ "$NEW_COUNT" != "$OLD_COUNT" ] || [ "${{ inputs.force_recategorize }}" == "true" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "Found changes: $OLD_COUNT -> $NEW_COUNT repos"
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "No previous cache, will categorize"
fi
- name: Categorize repositories
if: steps.check-changes.outputs.changes == 'true' || inputs.force_recategorize
env:
GH_USERNAME: ${{ github.repository_owner }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: |
PROVIDER_ARG=""
if [ "${{ inputs.provider }}" != "auto" ] && [ -n "${{ inputs.provider }}" ]; then
PROVIDER_ARG="--provider ${{ inputs.provider }}"
fi
PREFS="${{ inputs.preferences }}"
if [ -z "$PREFS" ]; then
# Default preferences - customize for your use case
PREFS="Organize repositories for a developer interested in DevOps, self-hosting, automation, web development, and AI/ML tools."
fi
starred categorize \
--input data/starred_cache.json \
--output-dir . \
--preferences "$PREFS" \
$PROVIDER_ARG
# Save current cache as previous for next run
cp data/starred_cache.json data/previous_cache.json
- name: Commit and push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add STARRED_REPOS.md starred_data.json data/
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: update starred repositories [skip ci]"
git push
fi
- name: Create summary
run: |
echo "## 📊 Starred Repos Update Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f "starred_data.json" ]; then
TOTAL=$(jq '.total_repos' starred_data.json)
CATS=$(jq '.category_count' starred_data.json)
PROVIDER=$(jq -r '.llm_provider' starred_data.json)
MODEL=$(jq -r '.llm_model' starred_data.json)
echo "**Total repositories:** $TOTAL" >> $GITHUB_STEP_SUMMARY
echo "**Categories:** $CATS" >> $GITHUB_STEP_SUMMARY
echo "**LLM:** $PROVIDER ($MODEL)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Categories" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
jq -r '.categories | to_entries | sort_by(-.value.count) | .[] | "- **\(.key)**: \(.value.count) repos"' starred_data.json >> $GITHUB_STEP_SUMMARY
else
echo "No categorization data found." >> $GITHUB_STEP_SUMMARY
fi