Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/update-badges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Update Badges

on: # yamllint disable-line rule:truthy
push:
pull_request:
branches: ["main"]
workflow_dispatch: # Allow manual triggering

Expand All @@ -14,6 +14,7 @@ jobs:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -33,11 +34,17 @@ jobs:
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Commit changes
- name: Commit and push changes
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "docs: update problem count badges [skip ci]"
git push

# Get the current branch name from the GitHub context
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
echo "Pushing to branch: $BRANCH_NAME"

# Push to the correct branch
git push origin HEAD:$BRANCH_NAME
2 changes: 1 addition & 1 deletion scripts/update_badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def update_readme_badges(cpp_count, python_count):

# Define the new badge lines
cpp_badge = f"[![C++ Solutions](https://img.shields.io/badge/C%2B%2B%20Solutions-{cpp_count}-blue?style=for-the-badge&logo=cplusplus&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems)"
python_badge = f"[![Python Solutions](https://img.shields.io/badge/Python%20Solutions-{python_count}-green?style=for-the-badge&logo=python&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems)"
python_badge = f"[![Python Solutions](https://img.shields.io/badge/Python%20Solutions-{python_count}-blue?style=for-the-badge&logo=python&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems)"

# Update C++ badge
cpp_pattern = r"\[\!\[C\+\+ Solutions\].*?\)\]\(.*?\)"
Expand Down