Update README.md #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Watchers Count | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
jobs: | ||
update-readme: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Fetch watchers count | ||
run: | | ||
WATCHERS_JSON=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/SeyedMuhammadHosseinMousavi/CHFP-DVAE-Conditional-Hierarchical-Fuzzy-PSO-Disentangled-VAE/subscribers") | ||
WATCHERS=$(echo "$WATCHERS_JSON" | jq '. | length') | ||
echo "WATCHERS_COUNT=$WATCHERS" | ||
echo "WATCHERS_COUNT=$WATCHERS" >> $GITHUB_ENV | ||
- name: Display watchers count | ||
run: echo "Number of Watchers: ${{ env.WATCHERS_COUNT }}" | ||
- name: Update README | ||
run: | | ||
sed -i "s/Total Watchers:.*/Total Watchers: ${{ env.WATCHERS_COUNT }}/g" README.md | ||
cat README.md | ||
- name: Commit and push if changes | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Action" | ||
git add README.md | ||
git commit -m "Updated Watchers Count" -a || echo "No changes to commit" | ||
git push |