Update badges #43
This file contains hidden or 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
| # Update README badges | |
| on: | |
| schedule: | |
| # Run weekly on Sundays at 00:00 UTC | |
| - cron: '0 0 * * 0' | |
| workflow_dispatch: | |
| name: Update badges | |
| jobs: | |
| update-badges: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Update README badges | |
| run: | | |
| # Define badge URLs | |
| R_CMD_CHECK="[](https://github.com/bbuchsbaum/fmrireg/actions/workflows/R-CMD-check.yaml)" | |
| CODECOV="[](https://app.codecov.io/gh/bbuchsbaum/fmrireg?branch=main)" | |
| LICENSE="[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)" | |
| LIFECYCLE="[](https://lifecycle.r-lib.org/articles/stages.html#experimental)" | |
| # Check if README.md exists, if not check README.rmd | |
| if [ -f "README.md" ]; then | |
| README_FILE="README.md" | |
| elif [ -f "README.rmd" ]; then | |
| README_FILE="README.rmd" | |
| else | |
| echo "No README file found" | |
| exit 1 | |
| fi | |
| echo "Updating badges in $README_FILE" | |
| # Create a temporary file with updated content | |
| { | |
| echo "# fmrireg" | |
| echo "" | |
| echo "$R_CMD_CHECK" | |
| echo "$CODECOV" | |
| echo "$LICENSE" | |
| echo "$LIFECYCLE" | |
| echo "" | |
| # Keep the rest of the file after the first empty line following badges | |
| tail -n +10 "$README_FILE" 2>/dev/null || echo "<!-- Add your package description here -->" | |
| } > README_temp.md | |
| # Replace the original file | |
| mv README_temp.md "$README_FILE" | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "actions@github.com" | |
| git config --local user.name "GitHub Actions" | |
| git add README.md README.rmd 2>/dev/null || true | |
| git diff --staged --quiet || git commit -m "Update README badges [skip ci]" | |
| git push |