Skip to content

Update README with Topics #32

Update README with Topics

Update README with Topics #32

name: Update README with Topics
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Fetch current Topics via GitHub API
id: get_topics
run: |
RESPONSE=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/topics)
TOPIC_NAMES=$(echo "$RESPONSE" | jq -r '.names | join(",")')
echo "names=$TOPIC_NAMES" >> $GITHUB_OUTPUT
- name: Update README with current Topics
id: update_readme
run: |
BULLET_LIST=$(echo ${{ steps.get_topics.outputs.names }} | sed 's/,/\n- /g')
sed -i "/<!-- START:topics -->/,/<!-- END:topics -->/c\\<!-- START:topics -->\n- $BULLET_LIST\n<!-- END:topics -->" README.md
- name: Commit and Push changes (if any)
run: |
if [ -n "$(git status --porcelain)" ]; then
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add README.md
git commit -m "Auto-update README with latest topics"
git push
else
echo "No changes to commit."
fi