Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GHA actions for docs deployment #38

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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: true

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

- name: Upload documentation
uses: actions/upload-artifact@v3
with:
name: sphinx-docs
path: docs/build/html

- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v1
with:
# Upload build sphinx docs
path: 'docs/build/html'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
29 changes: 1 addition & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
run: |
python -m pytest

package_docs:
package:
needs: test
runs-on: ubuntu-latest

Expand Down Expand Up @@ -113,34 +113,7 @@ jobs:
with:
name: python-packages
path: dist
- name: Build Sphinx Documentation
run: |
# install so that setuptools_scm generate version for package
pip install -r docs/requirements.txt -e .
make -C docs html
env:
PIP_EXTRA_INDEX_URL: https://${{secrets.ARTIFACTORY_RO_USER}}:${{secrets.ARTIFACTORY_RO_TOKEN}}@artifactory.niaid.nih.gov/artifactory/api/pypi/bcbb-pypi/simple

- name: Upload documentation
if: github.event_name == 'push'
uses: actions/upload-artifact@v3
with:
name: sphinx-docs
path: docs/_build/html
- name: Update gh-pages
if: github.ref == 'refs/heads/master'
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'
publish_release:
if: startsWith(github.ref, 'refs/tags/v')
needs: package_docs
Expand Down