tstor/.github/workflows/mkdocs.yml

73 lines
2.6 KiB
YAML
Raw Normal View History

2021-10-07 17:27:19 +00:00
name: mkdocs
on:
push:
branches:
- master
tags:
- 'v*'
jobs:
mkdocs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
# git-revision-date-localized-plugin and mkdocs-rss-plugin need full git history depth
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2.2.2
with:
python-version: "3.x"
- uses: actions/cache@v2.1.6
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
2021-10-07 17:10:46 +00:00
working-directory: ./mkdocs
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
- name: Build docs
2021-10-07 17:10:46 +00:00
working-directory: ./mkdocs
run: |
mkdocs build
2021-10-07 17:27:19 +00:00
# - name: Validate generated HTML files
# working-directory: ./mkdocs
# run: |
# docker run -v $(pwd):/test --rm wjdp/htmltest --conf .htmltest.yml
# On push to master or release branch, deploy docs
- name: Set up git author
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/v')
run: |
remote_repo="https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote rm origin
git remote add origin "${remote_repo}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy docs (Latest)
if: github.ref == 'refs/heads/master'
2021-10-07 17:36:25 +00:00
working-directory: ./mkdocs
run: |
echo "${CUSTOM_DOMAIN}" > "${GITHUB_WORKSPACE}/mkdocs/docs/CNAME"
2021-10-07 17:31:26 +00:00
echo -e "User-agent: *\nDisallow: /v*.*/\nSitemap: https://${CUSTOM_DOMAIN}/sitemap.xml" > "${GITHUB_WORKSPACE}/mkdocs/docs/robots.txt"
git fetch origin gh-pages --verbose
2021-10-07 17:52:47 +00:00
mike deploy master dev --config-file "${GITHUB_WORKSPACE}/mkdocs/mkdocs.yml" --push --rebase
env:
2021-10-07 17:36:25 +00:00
CUSTOM_DOMAIN: distribyted.com
- name: Deploy docs (Self-hosted)
if: startsWith(github.ref, 'refs/heads/release/v')
run: |
git fetch origin gh-pages --verbose
2021-10-07 17:36:25 +00:00
mike deploy ${GITHUB_REF##*/release/} -t "Self-hosted ${GITHUB_REF##*/release/}" --config-file "${GITHUB_WORKSPACE}/mkdocs/mkdocs.yml" --push --rebase