diff --git a/.gitea/update-readme.yml b/.gitea/update-readme.yml new file mode 100644 index 0000000..ccf645d --- /dev/null +++ b/.gitea/update-readme.yml @@ -0,0 +1,29 @@ +name: Auto-update README + +on: + push: + branches: [main] + +jobs: + update-readme: + runs-on: ubuntu-latest + steps: + - name: Клонировать репозиторий + uses: actions/checkout@v4 + with: + token: ${{ secrets.ACTIONS_TOKEN }} + + - name: Запустить Python-скрипт + run: python3 scripts/update_readme.py + + - name: Закоммитить изменения, если есть + run: | + git config user.name "README Bot" + git config user.email "bot@example.com" + if git diff --quiet README.md; then + echo "Изменений нет" + else + git add README.md + git commit -m "Автообновление README [skip ci]" + git push + fi \ No newline at end of file diff --git a/README.md b/README.md index 119c403..be7f7bb 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Проект сайта-портфолио программиста. + + ## Функциональность - Компетенции и решения - Отзывы клиентов @@ -15,3 +17,5 @@ pip install -r requirements.txt python manage.py migrate python manage.py collectstatic python manage.py createsuperuser + + \ No newline at end of file diff --git a/scripts/update_readme.py b/scripts/update_readme.py new file mode 100644 index 0000000..a76f066 --- /dev/null +++ b/scripts/update_readme.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import os +import re + +README_PATH = "README.md" +START_MARKER = "" +END_MARKER = "" + +def generate_structure(): + """Создаёт список файлов и папок в корне репозитория.""" + items = [] + for name in sorted(os.listdir(".")): + if name.startswith('.') or name == 'scripts': + continue + icon = "📁" if os.path.isdir(name) else "📄" + items.append(f"- {icon} {name}") + return "\n".join(items) + +def update_readme(): + with open(README_PATH, "r", encoding="utf-8") as f: + content = f.read() + + new_block = generate_structure() + pattern = re.compile( + re.escape(START_MARKER) + r".*?" + re.escape(END_MARKER), + re.DOTALL + ) + replacement = START_MARKER + "\n" + new_block + "\n" + END_MARKER + + if pattern.search(content): + new_content = pattern.sub(replacement, content) + else: + new_content = content.strip() + "\n\n" + replacement + "\n" + + with open(README_PATH, "w", encoding="utf-8") as f: + f.write(new_content) + +if __name__ == "__main__": + update_readme() \ No newline at end of file