Add commit step to actions

This commit is contained in:
Chuck Smith 2024-07-15 08:10:12 -04:00
parent 6ebe8c73ae
commit 49c42fbaac
3 changed files with 13 additions and 1 deletions

View File

@ -19,3 +19,12 @@ jobs:
- name: Count list items and update README
run: python3 src/update_banner.py
- name: Commit changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "Update list count in README" -a || echo "No changes to commit"
git push

View File

@ -9,7 +9,7 @@ This repo was inspired by [Ali Spittel's](https://twitter.com/ASpittel) tweet
Hopefully this repo can serve as a source of inspiration for your portfolio!
## Current List Count: 4
## Current List Count: 613
---

View File

@ -12,12 +12,15 @@ with open(readme_path, 'r', encoding='utf-8') as file:
# Count the list items
list_count = len(re.findall(r'^\s*-\s', readme_contents, re.MULTILINE))
print(list_count)
# Define the new banner message
new_banner = f'## Current List Count: {list_count}'
print(new_banner)
# Replace old banner with new banner in README
new_readme_contents = re.sub(r'## Current List Count: \d+', new_banner, readme_contents)
print(new_readme_contents)
# Save the changes back to README.md
with open(readme_path, 'w', encoding='utf-8') as file: