-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1592 from eclectic-coding/add_new-banner
Add update banner
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Update List Count Banner | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: | ||
- master | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
update-banner: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Count list items and update README | ||
run: python3 src/update_banner.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import re | ||
|
||
# Load the README file | ||
with open('README.md', 'r') as file: | ||
readme_contents = file.read() | ||
|
||
# Count the list items | ||
list_count = len(re.findall(r'^\s*[-*]\s', readme_contents, re.MULTILINE)) | ||
|
||
# Define the new banner message | ||
new_banner = f'## Current List Count: {list_count}' | ||
|
||
# Replace old banner with new banner in README | ||
new_readme_contents = re.sub(r'## Current List Count: \d+', new_banner, readme_contents) | ||
|
||
# Save the changes back to README.md | ||
with open('README.md', 'w') as file: | ||
file.write(new_readme_contents) |