Romm refactor #9
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: Docs | |
on: | |
push: | |
tags: ["v*.*.*"] | |
branches: ["main"] | |
paths: | |
- "docs/**" | |
- "mkdocs.yml" | |
pull_request: | |
paths: | |
- "docs/**" | |
- "mkdocs.yml" | |
merge_group: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
pre-commit: | |
name: Linting Checks | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Check files | |
uses: pre-commit/[email protected] | |
test: | |
name: Test Build | |
if: github.repository == 'gethomepage/homepage' && github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
needs: | |
- pre-commit | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
with: | |
key: mkdocs-material-${{ env.cache_id }} | |
path: .cache | |
restore-keys: | | |
mkdocs-material- | |
- run: sudo apt-get install pngquant | |
- run: pip install mike | |
- run: pip install mkdocs-material mkdocs-redirects "mkdocs-material[imaging]" | |
- name: Test Docs Build | |
run: MKINSIDERS=false mkdocs build | |
deploy: | |
name: Build & Deploy | |
if: github.repository == 'gethomepage/homepage' && github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
needs: | |
- pre-commit | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: main | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- run: echo "cache_id=${{github.sha}}" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
with: | |
key: mkdocs-material-${{ env.cache_id }} | |
path: .cache | |
restore-keys: | | |
mkdocs-material- | |
- run: sudo apt-get install pngquant | |
- run: pip install mike==2.0.0 | |
- run: pip install git+https://${GH_TOKEN}@github.com/benphelps/mkdocs-material-insiders.git | |
- run: pip install mkdocs-redirects "mkdocs-material[imaging]" | |
- name: Set Git config | |
run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "[email protected]" | |
- name: Sync gh-pages | |
run: | | |
git fetch origin gh-pages | |
git checkout gh-pages | |
git pull origin gh-pages | |
git checkout main | |
- name: Docs Deploy for Main | |
if: github.ref == 'refs/heads/main' | |
run: MKINSIDERS=true mike deploy --update --push ${{github.ref_name}} | |
- name: Docs Deploy for Tags | |
if: github.ref != 'refs/heads/main' | |
run: MKINSIDERS=true mike deploy --update --push ${{github.ref_name}} latest | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} |