Skip to content

Update GitHub Stats SVG #3877

Update GitHub Stats SVG

Update GitHub Stats SVG #3877

Workflow file for this run

name: Update GitHub Stats SVG
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Generate GitHub stats SVG
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXCLUDED_LANGS: ${{ secrets.EXCLUDED_LANGS }}
EXCLUDED_REPOS: ${{ secrets.EXCLUDED_REPOS }}
run: |
node src/generators/stats_commits.js
node src/generators/stats_general.js
node src/generators/stats_langs.js
node src/generators/stats_visitors.js
- name: Setup Git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Switch to the main branch
run: |
git fetch origin main
git checkout main
git pull origin main
- name: Indexing and adding SVG
run: |
git add output/*.svg
- name: Commit and push updated SVG
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
git commit -m "chore: update GitHub stats SVG (manual run)" --allow-empty
git push origin main
else
if git diff --cached --quiet; then
echo "No changes found, commit skipped."
else
git commit -m "chore: update GitHub stats SVG"
git push origin main
fi
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}