-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (52 loc) · 1.56 KB
/
update-readme.yml
File metadata and controls
59 lines (52 loc) · 1.56 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
name: Update README with Projects
on:
schedule:
- cron: '0 */12 * * *' # Every 12 hours (UTC)
workflow_dispatch:
jobs:
update-readme:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Fetch projects
run: |
curl -sf "${{ secrets.PROJECTS_API_URL }}" -o /tmp/projects.md
if [ ! -s /tmp/projects.md ]; then
echo "Failed to fetch projects or empty response"
exit 1
fi
- name: Ensure markers exist
run: |
if ! grep -q "<!-- PROJECTS:START -->" README.md; then
echo "<!-- PROJECTS:START -->" >> README.md
echo "<!-- PROJECTS:END -->" >> README.md
fi
- name: Update README block safely
run: |
awk '
/<!-- PROJECTS:START -->/ {
print
while ((getline line < "/tmp/projects.md") > 0)
print line
close("/tmp/projects.md")
skip=1
next
}
/<!-- PROJECTS:END -->/ {
skip=0
print
next
}
!skip
' README.md > README.new && mv README.new README.md
- name: Commit changes if needed
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff --quiet README.md || (
git add README.md
git commit -m "chore: update projects"
git push
)