Merge pull request #4 from astropy/workflow_repo_trigger #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docs | |
on: | |
push: | |
branches: | |
- main | |
# when a review is requested on a PR that targets `main`, or the PR is closed: | |
# pull_request: | |
# types: [review_requested, closed] | |
# Prevent multiple PRs from building/deploying the docs at the same time | |
concurrency: | |
group: ${{ github.workflow }} | |
jobs: | |
docs-build: | |
name: Build docs | |
runs-on: ubuntu-latest | |
if: (github.repository == 'astropy/repo_stats') | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
- name: Install docs dependencies | |
run: | | |
sudo apt-get install pandoc | |
pip install setuptools --upgrade | |
pip install .[test,docs] | |
- name: Make docs | |
run: | | |
pip install . | |
cd docs | |
make html | |
# upload the built docs as an artifact so the files can be accessed | |
# by a subsequent job in the workflow. | |
# only store the artifact for 'retention-days' | |
- name: Upload docs artifact | |
# if: github.event.pull_request.merged == true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: built_docs | |
path: docs/_build/html | |
retention-days: 1 | |
docs-deploy: | |
name: Deploy docs | |
needs: docs-build | |
runs-on: ubuntu-latest | |
if: (github.repository == 'astropy/repo_stats') | |
# if: github.event.pull_request.merged == true | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
# download the previously uploaded 'built_docs' artifact | |
- name: Download docs artifact | |
uses: actions/download-artifact@v4 | |
id: download | |
with: | |
name: built_docs | |
path: docs/_build/html | |
- name: Echo download path | |
run: echo ${{steps.download.outputs.download-path}} | |
- name: Disable jekyll builds | |
run: touch docs/_build/html/.nojekyll | |
- name: Display docs file structure | |
run: ls -aR | |
working-directory: docs/_build/html | |
- name: Install and configure dependencies | |
run: | | |
npm install -g --silent [email protected] | |
- name: Deploy docs to gh-pages branch | |
run: | | |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
npx gh-pages --dotfiles --dist docs/_build/html --user "github-actions-bot <[email protected]>" --message "Update docs [skip ci]" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |