Skip to content

Commit

Permalink
Publish PR preview docs (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
FasterSpeeding authored Nov 22, 2022
1 parent c1a2212 commit a5b2849
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 42 deletions.
36 changes: 4 additions & 32 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Run checks

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches: [ master ]
Expand All @@ -10,38 +14,6 @@ on:
workflow_dispatch:

jobs:
docs:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- name: Fetch merge branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: install prerequisites
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r ./dev-requirements/nox.txt
- name: Build docs
run: |
mkdir site
python -m nox -s generate-docs -- -o ./site
- name: Archive docs
uses: actions/upload-artifact@v3
with:
name: docs
path: ./site
if-no-files-found: error

lint:
runs-on: ubuntu-latest

Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/pr-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy PR preview docs

concurrency:
group: preview-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed

jobs:
deploy-docs-preview:
runs-on: ubuntu-latest

steps:
- name: Fetch merge branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python 3.9
if: github.event.action != 'closed'
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: install prerequisites
if: github.event.action != 'closed'
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r ./dev-requirements/nox.txt
- name: Build docs
if: github.event.action != 'closed'
run: |
mkdir site
python -m nox -s generate-docs -- -o ./site
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./site/
preview-branch: docs
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:

jobs:
publish-docs:
uses: ./.github/workflows/publish-docs.yml
uses: ./.github/workflows/release-docs.yml

publish:
runs-on: ubuntu-latest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ jobs:
echo "::set-output name=GIT_HASH::$(git rev-parse HEAD)"
- name: Push
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: docs
FOLDER: ./site
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MESSAGE: "${{ steps.doc_info.outputs.GIT_HASH }} docs (${{ github.event.release.tag_name || github.event.ref }})"
SKIP_EMPTY_COMMITS: true
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./site
branch: docs
commit-message: "${{ steps.doc_info.outputs.GIT_HASH }} docs (${{ github.event.release.tag_name || github.event.ref }})"
clean-exclude: pr-preview
1 change: 0 additions & 1 deletion docs/CNAME

This file was deleted.

0 comments on commit a5b2849

Please sign in to comment.