asix/.forgejo/workflows/mkdocs_publish.yaml
lordwektabyte 1506930576
All checks were successful
/ build (push) Successful in 31s
Remove unnecessary dependency installed
2023-12-31 17:32:51 +01:00

46 lines
1.4 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 -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
- uses: actions/upload-artifact@v3
with:
name: mkdocs-publish
path: public
- 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