Generate BioLib Runs Badge #97
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: Generate BioLib Runs Badge | |
on: | |
push: | |
paths: | |
- '.github/workflows/pprcode_biolib_runs_daily.yml' # Monitor the entire 'docker' directory | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
generate-badge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: badge | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
pip3 install pybiolib | |
- name: Fetch BioLib Runs count | |
run: | | |
echo "BIOLIB_RUNS=$(BIOLIB_TOKEN='${{ secrets.BIOLIB_TOKEN }}' python scripts/biolib_runcount.py)" >> $GITHUB_ENV | |
echo "BIOLIB_RUNS: ${{ env.BIOLIB_RUNS }}" | |
- name: Backup old badge | |
run: mv image/badges/BioLib_Runs_badge.svg image/badges/BioLib_Runs_badge.svg.bak | |
- name: Fetch new badge | |
run: | | |
curl -o image/badges/BioLib_Runs_badge.svg "https://img.shields.io/badge/BioLib_Runs-${{ env.BIOLIB_RUNS }}-55b5a6" | |
- name: Compare old and new badge to create a git commit | |
id: compare_badges | |
run: | | |
if [[ "$(diff -q image/badges/BioLib_Runs_badge.svg image/badges/BioLib_Runs_badge.svg.bak)" == "" ]]; then | |
echo "Badges are the same. Skipping the rest of the steps." | |
else | |
echo "Badges are differed. Creating a new commit." | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git add image/badges/BioLib_Runs_badge.svg | |
git commit -m "Update BioLib run number to ${{ env.BIOLIB_RUNS }}" | |
git push origin badge | |
fi | |