Deploy documentation #71
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: Deploy documentation | |
# Check for reference: | |
# https://github.com/s1rius/ezlog/blob/20dce11e6d324bb18f57dc7c7c6d4a8bf40064de/.github/workflows/publish_pages.yml | |
on: | |
schedule: | |
- cron: "40 03 */2 * *" # Runs at 03:40, every 2 days | |
push: | |
branches: | |
- main | |
paths: | |
- docs/** | |
- .github/workflows/deploy_docs.yml | |
- README*.md | |
workflow_dispatch: | |
concurrency: | |
group: pages | |
cancel-in-progress: true | |
env: | |
runner: ubuntu-latest | |
cache-mkdocs-key: cache-mkdocs | |
SITE_SUFFIX: /bazzite/ | |
REPO_URL: ${{ github.server_url }}/${{ github.repository }} | |
jobs: | |
deploy: | |
permissions: | |
contents: read # To push a branch | |
pages: write # To push to a GitHub Pages site | |
id-token: write # To update the deployment status | |
runs-on: ubuntu-latest | |
# environment: | |
# name: github-pages | |
# url: ${{ steps.deployment.outputs.page_url }} | |
defaults: | |
run: | |
working-directory: ./docs | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Prepare env vars | |
run: | | |
_OWNER_NAME=${{ github.repository_owner }} | |
_OWNER_NAME=${_OWNER_NAME,,} | |
_SITE_PREFIX=${{ env.SITE_SUFFIX }} | |
_SITE_PREFIX=${_SITE_PREFIX#/} | |
echo "SITE_URL=https://${_OWNER_NAME}.github.io/$_SITE_PREFIX" >> $GITHUB_ENV | |
# Necessary in order to have fetch_discourse_md.py available for mdbook-cmd | |
- name: Add docs/utils to PATH | |
run: | | |
echo $PWD/utils:$PATH >> $GITHUB_PATH | |
- name: Build book | |
uses: ./.github/workflows/build_mkdocs | |
with: | |
site_url: ${{ env.SITE_URL }} | |
repo_url: ${{ env.REPO_URL }} | |
working_dir: ${{ github.workspace }}/docs | |
output_dir: ${{ github.workspace }}/book | |
upload_github_page: "true" | |
github_token: ${{ github.token }} | |
clean_cache: | |
needs: deploy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
actions: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache Cleanup | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
set -x | |
old_caches=($(gh cache list \ | |
--repo ${{ github.repository }} \ | |
--key "${{ runner.os }}-build-${{ env.cache-mkdocs-key }}-" \ | |
--sort created_at -O asc --json id | jq '.[:-1][].id')) | |
for id in "${old_caches[@]}"; do | |
gh cache delete $id | |
done | |
- name: Remove Page Artifacts | |
uses: remagpie/gha-remove-artifact@v1 | |
with: | |
only-name: github-pages | |
max-age: 7776000 # 90 days | |
max-count: 50 |