From 767bf00003234f2be8ad32f55b7d272122dbecfb Mon Sep 17 00:00:00 2001 From: mathusanm6 Date: Sun, 31 Aug 2025 11:27:50 +0200 Subject: [PATCH 1/5] fix: update badges workflow fails trying to push to main --- .github/workflows/update-badges.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-badges.yml b/.github/workflows/update-badges.yml index 8aa46d1..9f9c81c 100644 --- a/.github/workflows/update-badges.yml +++ b/.github/workflows/update-badges.yml @@ -2,7 +2,7 @@ name: Update Badges on: # yamllint disable-line rule:truthy - push: + pull_request: branches: ["main"] workflow_dispatch: # Allow manual triggering From a0954aa5a8798a3bccbade5b276425dff419151c Mon Sep 17 00:00:00 2001 From: mathusanm6 Date: Sun, 31 Aug 2025 11:29:50 +0200 Subject: [PATCH 2/5] fix: error on push --- .github/workflows/update-badges.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-badges.yml b/.github/workflows/update-badges.yml index 9f9c81c..3b876c9 100644 --- a/.github/workflows/update-badges.yml +++ b/.github/workflows/update-badges.yml @@ -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 @@ -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 From 10fe3e285f8a2219ab63919cfeae5d784770df41 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 31 Aug 2025 09:30:04 +0000 Subject: [PATCH 3/5] docs: update problem count badges [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e194b03..7405345 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [![Last Commit](https://img.shields.io/github/last-commit/mathusanm6/LeetCode?style=for-the-badge&logo=git&logoColor=white&color=blue)](https://github.com/mathusanm6/LeetCode/commits/main) [![C++ Solutions](https://img.shields.io/badge/C%2B%2B%20Solutions-3-blue?style=for-the-badge&logo=cplusplus&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems) -[![Python Solutions](https://img.shields.io/badge/Python%20Solutions-3-blue?style=for-the-badge&logo=python&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems) +[![Python Solutions](https://img.shields.io/badge/Python%20Solutions-3-green?style=for-the-badge&logo=python&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems) From 8a4591e6c55f691dd258f6f4e4cfa0b1452501d3 Mon Sep 17 00:00:00 2001 From: mathusanm6 Date: Sun, 31 Aug 2025 11:32:24 +0200 Subject: [PATCH 4/5] fix: color --- scripts/update_badges.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_badges.py b/scripts/update_badges.py index 1d6ba85..81d32ec 100644 --- a/scripts/update_badges.py +++ b/scripts/update_badges.py @@ -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\].*?\)\]\(.*?\)" From 8aa7cf9c951efc9e61a15390f8decca01c13f82e Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 31 Aug 2025 09:32:39 +0000 Subject: [PATCH 5/5] docs: update problem count badges [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7405345..e194b03 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [![Last Commit](https://img.shields.io/github/last-commit/mathusanm6/LeetCode?style=for-the-badge&logo=git&logoColor=white&color=blue)](https://github.com/mathusanm6/LeetCode/commits/main) [![C++ Solutions](https://img.shields.io/badge/C%2B%2B%20Solutions-3-blue?style=for-the-badge&logo=cplusplus&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems) -[![Python Solutions](https://img.shields.io/badge/Python%20Solutions-3-green?style=for-the-badge&logo=python&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems) +[![Python Solutions](https://img.shields.io/badge/Python%20Solutions-3-blue?style=for-the-badge&logo=python&logoColor=white)](https://github.com/mathusanm6/LeetCode/tree/main/problems)