asix/.forgejo/workflows/mkdocs_publish.yaml
lordwektabyte 67cf06909d
All checks were successful
/ build (push) Successful in 34s
Restore mkdocs config for not main build
2023-12-31 16:41:52 +01:00

42 lines
1.3 KiB
YAML

on:
push:
branches:
- main
- develop
stages:
- build
env:
PUBLISH_BRANCH: ${{ github.ref == 'refs/heads/main' && 'pages' || 'draft' }}
BUILD_STRICT: ${{ github.ref == 'refs/heads/main' && '--strict' || '' }}
DRAFT_PRIMARY_COLOR: orange
DRAFT_ACCENT_COLOR: deep orange
jobs:
build:
runs-on: docker
steps:
- run: apt-get update && apt-get install python3-pip tree -y
- uses: https://code.forgejo.org/actions/checkout@v4
with:
fetch-depth: 0
- run: git config user.email "lordwektabyte@duck.com"
- run: git config user.name "lordwektabyte"
- run: pip install -r requirements.txt
- run: |
if [ "$PUBLISH_BRANCH" != "pages" ]; then
sed -i "0,/^\([[:space:]]*primary: *\).*/s//\1$DRAFT_PRIMARY_COLOR/;0,/\([[:space:]]*accent: *\).*/s//\1$DRAFT_ACCENT_COLOR/;" mkdocs.yml
fi
- run: mkdocs build --verbose --site-dir public $BUILD_STRICT
- run: |
if [ "$PUBLISH_BRANCH" != "pages" ]; then
git restore mkdocs.yml
fi
- run: cp .domains public/.domains
- run: git switch --orphan $PUBLISH_BRANCH
- run: git add public
- run: git mv public/{.[!.],}* .
- run: git commit -m "Mkdocs Build"
- run: git push -u origin $PUBLISH_BRANCH -f