mirror of
https://github.com/emmabostian/developer-portfolios.git
synced 2025-01-23 01:46:00 +00:00
Add update banner
This commit is contained in:
parent
fd9fb1c207
commit
a403b7e04c
21
.github/workflows/update-banner.yml
vendored
Normal file
21
.github/workflows/update-banner.yml
vendored
Normal file
@ -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@v2
|
||||
|
||||
- name: Count list items and update README
|
||||
run: python3 update_banner.py
|
@ -9,6 +9,8 @@ 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: X
|
||||
|
||||
---
|
||||
|
||||
**Jump to:** [A](#a) | [B](#b) | [C](#c) | [D](#d) | [E](#e) | [F](#f) | [G](#g) | [H](#h) | [I](#i) | [J](#j) | [K](#k) | [L](#l) | [M](#m) | [N](#n) | [O](#o) | [P](#p) | [Q](#q) | [R](#r) | [S](#s) | [T](#t) | [U](#u) | [V](#v) | [W](#w) | [Y](#y) | [Z](#z)
|
||||
|
18
src/update_banner.py
Normal file
18
src/update_banner.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user