Skip to content

Commit

Permalink
Add commit step to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
eclecticCodingND committed Jul 15, 2024
1 parent 6ebe8c7 commit 49c42fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/update-banner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

---

Expand Down
3 changes: 3 additions & 0 deletions src/update_banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@

# 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:
Expand Down

0 comments on commit 49c42fb

Please sign in to comment.