Skip to content

Update update_clone_badge.yml #11

Update update_clone_badge.yml

Update update_clone_badge.yml #11

name: Update Clone Badge
on:
schedule:
- cron: '*/5 * * * *' # Runs every 5 minutes
push:
branches:
- v2.1.1-dev
jobs:
update-badge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get clone and download counts
id: get_counts gh_action

Check failure on line 21 in .github/workflows/update_clone_badge.yml

View workflow run for this annotation

GitHub Actions / Update Clone Badge

Invalid workflow file

The workflow is not valid. .github/workflows/update_clone_badge.yml (Line: 21, Col: 13): The identifier 'get_counts gh_action' is invalid. IDs may only contain alphanumeric characters, '_', and '-'. IDs must start with a letter or '_' and and must be less than 100 characters.
run: |
# Fetch clone count from GitHub API
CLONE_COUNT=$(curl -s -H "Authorization: Bearer ${{ secrets.GH_ACTION }}" \
https://api.github.com/repos/CDCgov/phoenix/traffic/clones \
| jq -r '.count')
# Fetch download count from GitHub API (example for fetching release download count)
DOWNLOAD_COUNT=$(curl -s -H "Authorization: Bearer ${{ secrets.GH_ACTION }}" \
https://api.github.com/repos/CDCgov/phoenix/releases \
| jq -r '.[] | select(.assets != null) | .assets[].download_count' \
| awk '{s+=$1} END {print s}')
echo "::set-output name=clone_count::$CLONE_COUNT"
echo "::set-output name=download_count::$DOWNLOAD_COUNT"
- name: Update README badge
run: |
sed -i "s|label=Clones.*)|label=Clones-${{ steps.get_counts.outputs.clone_count }})|" README.md
sed -i "s|label=Download.*)|label=Download-${{ steps.get_counts.outputs.download_count }})|" README.md
- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "HAISeq"
git add README.md
git commit -m "Update clone and download counts"
git push