71 lines
No EOL
2.2 KiB
YAML
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''
|
|
|
|
# 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 |