Validate Latest Release URLs #6
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
| name: Check and Update Badges | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at midnight UTC | |
| workflow_dispatch: # Allows manual trigger | |
| jobs: | |
| check-badges: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Switch to gh-pages branch | |
| run: git checkout gh-pages | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm install axios | |
| - name: Check and update badges.json | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: node check-badges.js | |
| - name: Clean up untracked files | |
| run: | | |
| rm -rf node_modules package-lock.json package.json | |
| - name: Check for changes | |
| run: | | |
| git add badges.json | |
| if git diff --cached --quiet; then | |
| echo "No changes detected." | |
| exit 0 | |
| fi | |
| - name: Set Git user identity | |
| run: | | |
| git config --local user.name "GitHub Actions Bot" | |
| git config --local user.email "[email protected]" | |
| - name: Create a new branch for the PR | |
| run: | | |
| git checkout -b update-badges-${{ github.run_id }} | |
| git commit -m "Update badges.json with latest release URLs" | |
| - name: Push the new branch | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: git push origin HEAD | |
| - name: Create a pull request | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| base: gh-pages | |
| branch: update-badges-${{ github.run_id }} | |
| title: "Update badges.json" | |
| body: | | |
| This pull request updates `badges.json` with the latest release URLs. | |
| Please review and merge if everything looks correct. | |
| labels: "automated update" | |
| assignees: "Garlicrot" |