Skip to content

Commit

Permalink
Publish mkdocs to github action on every update
Browse files Browse the repository at this point in the history
  • Loading branch information
b0g3r committed May 2, 2021
1 parent dbe4618 commit 5d56b76
Showing 1 changed file with 62 additions and 16 deletions.
78 changes: 62 additions & 16 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,103 @@ on:
branches:
- master
pull_request:

env:
PYTHON_VERSION: 3.9

jobs:
deployment:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2.3.1
uses: actions/checkout@v2

- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: ${{ env.PYTHON_VERSION }}

- name: Build docs 🏗
- name: Cache Poetry virtualenv 💾
uses: actions/cache@v1
id: poetry-cache
with:
path: .venv
key: poetry-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry 📖
run: |
pip install poetry
poetry config virtualenvs.in-project true
- name: Install dependencies 📌
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
poetry install
mkdocs build
env:
POETRY_VIRTUALENVS_CREATE: false
- name: Build docs 🏗
run: |
poetry run mkdocs build
- name: Upload build to artifact ☁️
uses: actions/upload-artifact@v2
with:
name: mkdocs-build
path: site
if-no-files-found: error

publish-docs-prod:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs:
- build-docs
steps:
- name: Download build from artifact 🌨
uses: actions/download-artifact@v1
with:
name: mkdocs-build

- name: Publish docs to Pages 🧐 [prod]
if: github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: gh-pages
folder: site
folder: mkdocs-build


publish-docs-preview:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs:
- build-docs
steps:
- name: Download build from artifact 🌨
uses: actions/download-artifact@v1
with:
name: mkdocs-build

- name: Publish to Surge 🧐 [preview]
id: publish-preview
if: github.event_name == 'pull_request'
env:
SURGE_LOGIN: dev@eventual.com
SURGE_TOKEN: 5ed7fcac90fac92170a28e638c01219b
run: |
pr_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
deploy_host="${pr_number}-eventual-review.surge.sh"
npx surge site $deploy_host
npx surge mkdocs-build $deploy_host
echo "::set-output name=deploy-url::https://$deploy_host"
- name: Find Comment 🔎
- name: Find existing comment 🔎
id: find-comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: preview version of docs

- name: Create comment
if: ${{ github.event_name == 'pull_request' && steps.find-commend.outputs.comment-id == ''}}
- name: Comment PR
if: steps.find-comment.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
This is a preview version of docs: ${{ steps.publish-preview.outputs.deploy-url }}
This is a preview version of docs: ${{ steps.publish-preview.outputs.deploy-url }}

0 comments on commit 5d56b76

Please sign in to comment.