Update update_readme.yml #12
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
name: Replace Text in README | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
update_readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
pip install mallm # if mallm is an external package, or install other dependencies as needed | |
- name: Replace Text in README | |
run: | | |
python -c " | |
from mallm.utils.config import Config | |
import re | |
config = Config(data=None, out=None, instruction=None) | |
attributes = {attr: getattr(config, attr) for attr in dir(config) if not callable(getattr(config, attr)) and not attr.startswith('__')} | |
with open('README.md', 'r+') as readme_file: | |
content = readme_file.read() | |
attributes_content = '' | |
for attr, value in attributes.items(): | |
attributes_content += f'{attr}: {value}\n' | |
replacement_str = '### Config Arguments:\n```py\n' + attributes_content + '```' | |
print(replacement_str) | |
updated_lines = re.sub(r'### Config Arguments:\n```py\n(.*?)```', replacement_str, content, flags=re.DOTALL) | |
readme_file.seek(0) | |
readme_file.writelines(updated_lines) | |
readme_file.truncate() | |
" | |
shell: bash | |
- name: Update README.md | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git add README.md | |
git commit -m 'Update README' | |
git push |