File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Update README with Topics
2
+
3
+ on :
4
+ schedule :
5
+ - cron : ' 0 0 * * *'
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ update-readme :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Check out repository
13
+ uses : actions/checkout@v3
14
+ - name : Fetch current Topics via GitHub API
15
+ id : get_topics
16
+ run : |
17
+ RESPONSE=$(curl -s \
18
+ -H "Accept: application/vnd.github.v3+json" \
19
+ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
20
+ https://api.github.com/repos/${{ github.repository }}/topics)
21
+ TOPIC_NAMES=$(echo "$RESPONSE" | jq -r '.names | join(",")')
22
+ echo "names=$TOPIC_NAMES" >> $GITHUB_OUTPUT
23
+ - name : Update README with current Topics
24
+ id : update_readme
25
+ run : |
26
+ BULLET_LIST=$(echo ${{ steps.get_topics.outputs.names }} | sed 's/,/\n- /g')
27
+ sed -i "/<!-- START:topics -->/,/<!-- END:topics -->/c\\<!-- START:topics -->\n- $BULLET_LIST\n<!-- END:topics -->" README.md
28
+
29
+ - name : Commit and Push changes (if any)
30
+ run : |
31
+ if [ -n "$(git status --porcelain)" ]; then
32
+ git config user.name "github-actions"
33
+ git config user.email "github-actions@github.com"
34
+ git add README.md
35
+ git commit -m "Auto-update README with latest topics"
36
+ git push
37
+ else
38
+ echo "No changes to commit."
You can’t perform that action at this time.
0 commit comments