mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-11 05:53:23 -05:00
106 lines
3.3 KiB
YAML
106 lines
3.3 KiB
YAML
name: Deploy Site
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "platforms/**"
|
|
- "emulators/**"
|
|
- "provenance/**"
|
|
- "wiki/**"
|
|
- "scripts/generate_site.py"
|
|
- "scripts/generate_readme.py"
|
|
- "scripts/verify.py"
|
|
- "scripts/common.py"
|
|
- "database.json"
|
|
- "mkdocs.yml"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
# Pages deployments must run to completion: cancelling one mid-flight
|
|
# leaves the deployment stuck and makes the next runs time out waiting
|
|
# on it. Queued runs collapse to the latest instead.
|
|
group: pages
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
|
|
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
# mkdocs-material >= 9.7.5 caps mkdocs < 2; the upper bound keeps a major
|
|
# theme release from changing the site without a deliberate bump here.
|
|
- run: pip install pyyaml "mkdocs-material>=9.7.5,<10" "pymdown-extensions>=10.14"
|
|
|
|
- name: Restore large files from release
|
|
run: |
|
|
mkdir -p .cache/large
|
|
gh release download large-files -D .cache/large/ 2>/dev/null || true
|
|
python3 -c "
|
|
import hashlib, json, os, shutil
|
|
db = json.load(open('database.json'))
|
|
with open('.gitignore') as f:
|
|
ignored = {l.strip() for l in f if l.strip().startswith('bios/')}
|
|
cache = '.cache/large'
|
|
if not os.path.isdir(cache):
|
|
exit(0)
|
|
idx = {}
|
|
for fn in os.listdir(cache):
|
|
fp = os.path.join(cache, fn)
|
|
if os.path.isfile(fp):
|
|
h = hashlib.sha1(open(fp, 'rb').read()).hexdigest()
|
|
idx[h] = fp
|
|
restored = 0
|
|
for sha1, entry in db['files'].items():
|
|
path = entry['path']
|
|
if path in ignored and not os.path.exists(path):
|
|
src = idx.get(sha1)
|
|
if src:
|
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
shutil.copy2(src, path)
|
|
print(f'Restored: {path}')
|
|
restored += 1
|
|
print(f'Total: {restored} files restored')
|
|
"
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Refresh data directories
|
|
run: python scripts/refresh_data_dirs.py
|
|
continue-on-error: true
|
|
|
|
- name: Generate site
|
|
run: |
|
|
python scripts/generate_site.py
|
|
python scripts/generate_readme.py --db database.json --platforms-dir platforms
|
|
mkdocs build --strict
|
|
|
|
- name: Setup Pages
|
|
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5
|
|
with:
|
|
path: site/
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5
|