Skip to content

Commit

Permalink
Update docs to directly push to pages.
Browse files Browse the repository at this point in the history
Enables removal of docs branch.
  • Loading branch information
blowekamp committed Mar 6, 2024
1 parent 0844d3f commit a4da9c2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 115 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy Sphinx docs static content to GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
docs-pages:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r docs/requirements.txt
python -m pip install -e .
- name: Build Sphinx Documentation
run: |
make -C docs html
rm docs/build/html/.buildinfo
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: sphinx-docs
path: docs/build/html

- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
with:
# Upload build sphinx docs
path: 'docs/build/html'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
33 changes: 5 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
python -m pytest
package_docs:
package:
needs: test
runs-on: ubuntu-latest
steps:
Expand All @@ -91,10 +91,10 @@ jobs:
- name: Git LFS Pull
run: |
git lfs pull
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -110,39 +110,16 @@ jobs:
with:
name: python-packages
path: dist
- name: Build Sphinx Documentation
run: |
python -m pip install dist/rap_sitkcore*.whl -r docs/requirements.txt
cd docs
make html
- name: Upload documentation
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: sphinx-docs
path: docs/_build/html
- name: Update gh-pages
if: github.ref == 'refs/heads/main'
run: |
rm docs/_build/html/.buildinfo
touch docs/_build/html/.nojekyll
git update-ref refs/heads/${TARGET_BRANCH} origin/${TARGET_BRANCH}
./utils/update-gh-pages.sh docs/_build/html
repo_uri="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push $repo_uri ${TARGET_BRANCH}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
TARGET_BRANCH: 'gh-pages'

github_publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: package_docs
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
87 changes: 0 additions & 87 deletions utils/update-gh-pages.sh

This file was deleted.

0 comments on commit a4da9c2

Please sign in to comment.