Auto update badges file #4526
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: Auto update badges file | |
on: | |
schedule: | |
# ┌─────────── minute (0 - 59) | |
# │ ┌────────── hour (0 - 23) | |
# │ │ ┌────────── day of the month (1 - 31) | |
# │ │ │ ┌────────── month (1 - 12 or JAN-DEC) | |
# │ │ │ │ ┌────────── day of the week (0 - 6 or SUN-SAT) | |
# │ │ │ │ │ | |
# │ │ │ │ │ | |
# │ │ │ │ │ | |
# * * * * * | |
- cron: "*/15 * * * *" | |
workflow_dispatch: | |
permissions: | |
actions: read | |
checks: read | |
contents: write | |
deployments: read | |
issues: read | |
discussions: read | |
packages: read | |
pages: read | |
pull-requests: write | |
repository-projects: read | |
security-events: read | |
statuses: read | |
jobs: | |
update-badge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Setup Node | |
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
with: | |
node-version: "22.x" | |
cache: npm | |
# Fix the unsafe repo error which was introduced by the CVE-2022-24765 git patches. | |
- name: Fix unsafe repo error | |
run: git config --global --add safe.directory ${{ github.workspace }} | |
- name: Run npm install and run scripts | |
run: | | |
npm install | |
npm run new-badge | |
env: | |
CI: true | |
- name: Set up Git | |
run: | | |
git config user.name "Barudak Rosul Bot" | |
git config user.email "178687547+barudakrosul-bot@users.noreply.github.com" | |
git config --global --add safe.directory ${GITHUB_WORKSPACE} | |
- name: Push commit to a new branch | |
run: | | |
branch="auto_update_badges" | |
message="chore: auto update badges file" | |
body=$(printf "_This pull request was created automatically._\n\n> Co-authored-by: Barudak Rosul Bot <178687547+barudakrosul-bot@users.noreply.github.com>") | |
if [[ "$(git status --porcelain)" != "" ]]; then | |
git branch -D ${branch} || true | |
git checkout -b ${branch} | |
git add images | |
git commit --message "${message}" | |
git remote add origin-${branch} "https://github.com/BarudakRosul/.github.git" | |
git push --force --quiet --set-upstream origin-${branch} ${branch} | |
gh pr create --title "${message}" --body "${body}" | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} |