ci: deploy docs on forks if they have pages enabled

This commit is contained in:
ThinkChaos 2023-05-11 21:34:10 -04:00
parent 8a93e4500c
commit 2bd59484c0
1 changed files with 12 additions and 10 deletions

View File

@ -2,32 +2,34 @@ name: docs
on:
push:
branches:
- main
- '**'
tags:
- v*
jobs:
deploy:
runs-on: ubuntu-latest
if: github.repository_owner == '0xERR0R'
if: ${{ github.event.repository.has_pages && (github.repository_owner != '0xERR0R' || github.ref_type == 'tag' || github.ref_name == 'main') }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: install tools
run: pip install mkdocs-material mike
- name: Setup doc deploy
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Deploy version for tag/branch
run: mike deploy --push --update-aliases ${GITHUB_REF_NAME}
- name: Deploy latest version for tag only
if: ${{ github.ref != 'refs/heads/main' }}
run: mike deploy --push --update-aliases ${GITHUB_REF_NAME} latest
- run: mike set-default --push latest
- name: Deploy version for branch
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: mike deploy --push --update-aliases "$(sed 's:/:-:g' <<< "${GITHUB_REF_NAME}")"
- name: Deploy version for tag and update latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: mike deploy --push --update-aliases "${GITHUB_REF_NAME}" latest