Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 9 additions & 2 deletions .github/workflows/update-badges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 correct branch name for pushing
BRANCH_NAME="${{ github.event_name == 'pull_request' && github.base_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