deb-mock/.forgejo/workflows/update-readme.yml
robojerk aaadb2d60a
Some checks failed
Build Deb-Mock Package / build (push) Failing after 3s
Test Deb-Mock Build / test (push) Failing after 1s
added forgejo workflow
2025-08-03 22:24:21 +00:00

71 lines
No EOL
2.2 KiB
YAML

name: Update README
on:
workflow_run:
workflows: ["Build Deb-Mock Package", "Test Deb-Mock Build"]
types:
- completed
jobs:
update-readme:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- name: Update README with build status
run: |
source venv/bin/activate
python -c "
import re
from datetime import datetime
# Read current README
with open('README.md', 'r') as f:
content = f.read()
# Update build status
build_status = f'![Build Status](https://github.com/{{\"{{ github.repository }}\"}}/workflows/Build%20Deb-Mock%20Package/badge.svg)'
# Update last updated timestamp
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S UTC')
# Replace or add build status
if '![Build Status]' in content:
content = re.sub(r'!\[Build Status\].*', build_status, content)
else:
# Add after the title
content = content.replace('# Deb-Mock', f'# Deb-Mock\n\n{build_status}')
# Update last updated
if 'Last updated:' in content:
content = re.sub(r'Last updated:.*', f'Last updated: {timestamp}', content)
else:
# Add after build status
content = content.replace(build_status, f'{build_status}\n\nLast updated: {timestamp}')
# Write updated README
with open('README.md', 'w') as f:
f.write(content)
"
- name: Commit and push changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
git diff --quiet && git diff --staged --quiet || git commit -m "Update README with build status"
git push