-
Notifications
You must be signed in to change notification settings - Fork 7
130 lines (108 loc) · 3.86 KB
/
Copy pathupdate-profile-readme.yml
File metadata and controls
130 lines (108 loc) · 3.86 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
name: Update Profile README
on:
# Trigger when STARRED_REPOS.md changes
push:
branches: [main]
paths:
- 'STARRED_REPOS.md'
- 'starred_data.json'
# Or trigger manually
workflow_dispatch:
inputs:
profile_repo:
description: 'Profile repo (username/username or org/.github)'
required: false
type: string
max_repos:
description: 'Max repos to show in README'
required: false
type: number
default: 200
max_categories:
description: 'Max categories to show'
required: false
type: number
default: 20
include_toc:
description: 'Include table of contents'
required: false
type: boolean
default: true
include_description:
description: 'Include repo descriptions'
required: false
type: boolean
default: true
jobs:
update-profile:
runs-on: ubuntu-latest
steps:
- name: Checkout starred repo
uses: actions/checkout@v4
with:
path: starred
- name: Determine profile repo
id: profile
run: |
PROFILE_REPO="${{ inputs.profile_repo }}"
if [ -z "$PROFILE_REPO" ]; then
# Default: user's profile repo (username/username)
PROFILE_REPO="${{ github.repository_owner }}/${{ github.repository_owner }}"
fi
echo "repo=$PROFILE_REPO" >> $GITHUB_OUTPUT
echo "Will update README in: $PROFILE_REPO"
- name: Checkout profile repo
uses: actions/checkout@v4
with:
repository: ${{ steps.profile.outputs.repo }}
token: ${{ secrets.PROFILE_REPO_TOKEN || secrets.GH_PAT }}
path: profile
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install starred
run: |
cd starred
pip install -e .
- name: Update profile README
env:
STARRED_REPO: ${{ github.repository }}
run: |
cd starred
# Check if profile README exists and has placeholders
PROFILE_README="../profile/README.md"
if [ ! -f "$PROFILE_README" ]; then
echo "Creating profile README with placeholders..."
starred update-readme --readme "$PROFILE_README" --create-template
fi
# Build command with optional flags
CMD="starred update-readme --readme $PROFILE_README --data starred_data.json"
CMD="$CMD --max-repos ${{ inputs.max_repos || 50 }}"
CMD="$CMD --max-categories ${{ inputs.max_categories || 10 }}"
CMD="$CMD --starred-repo-url https://github.com/$STARRED_REPO"
if [ "${{ inputs.include_toc }}" == "true" ]; then
CMD="$CMD --include-toc"
fi
if [ "${{ inputs.include_description }}" == "true" ]; then
CMD="$CMD --include-description"
fi
# Run the command
eval $CMD
- name: Copy full STARRED_REPOS.md to profile repo
run: |
cp starred/STARRED_REPOS.md profile/STARRED_REPOS.md
echo "✅ Copied STARRED_REPOS.md to profile repo"
- name: Commit and push to profile repo
run: |
cd profile
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md STARRED_REPOS.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: update starred repos section"
git push
echo "✅ Updated profile README and STARRED_REPOS.md"
fi