diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..e5ded14 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,43 @@ +name: Build and Test Documentation + +on: + pull_request: + branches: + - main + +jobs: + build_and_test: + name: Build and Test + runs-on: ubuntu-22.04 + environment: Testing + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10.12" + + - name: Install pipenv and dependencies + run: | + python -m pip install --upgrade pipenv wheel + pipenv install --deploy --dev + + - name: Build HTML pages + id: make_html + run: | + pipenv run make html SPHINXOPTS="-W --keep-going" # -W: Fail on warnings. --keep-going: Continue processing on warnings, but fail at the end + + - name: Check all external links + id: make_linkcheck + run: | + pipenv run make linkcheck SPHINXOPTS="-W --keep-going -n" # -n: nit-picky mode, generates warnings for all missing references + + - name: Upload docs + uses: actions/upload-artifact@v4 + with: + name: html + if-no-files-found: error + path: docs/html/* diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml new file mode 100644 index 0000000..f3518ec --- /dev/null +++ b/.github/workflows/deploy_docs.yml @@ -0,0 +1,44 @@ +name: Deploy Documentation + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-22.04 + environment: Production + + steps: + - name: Download html artifact + run: | + repo="${{ github.repository }}" + workflow="build_and_test.yml" + artifact="html" + run_id=`gh run --repo ${repo} list --workflow ${workflow} --json databaseId --jq .[0].databaseId` + mkdir html + cd html + gh run --repo ${repo} download ${run_id} -n ${artifact} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Commit documentation changes + run: | + git clone https://github.com/${{ github.repository_owner }}/miniscope-docs.git --branch gh-pages --single-branch gh-pages + cd gh-pages + rm -rf * + cp -r ../html/* . + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add . + git commit -m "Update documentation" -a || true + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Push changes + uses: ad-m/github-push-action@master + with: + branch: gh-pages + directory: gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml deleted file mode 100644 index 8b78636..0000000 --- a/.github/workflows/gh-pages.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Update Documentation - -on: - push: - branches: - - main - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - # 1. Generate HTML files - - name: Check out repository code - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install pipenv - run: | - python -m pip install --upgrade pipenv wheel - - - name: Install dependencies - run: | - pipenv install --deploy --dev - - - name: Make - run: | - pipenv run make html - - # 2. Add and commit HTML files to gh-pages branch - - name: Commit documentation changes - run: | - git clone https://github.com/${{ github.repository_owner }}/onix-docs.git --branch gh-pages --single-branch gh-pages - cd gh-pages - rm -rf * - cp -r ../docs/html/* . - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add . - git commit -m "Update documentation" -a || true - - # 3. Push changes to gh-pages branch (updates documentation page) - - name: Push changes - uses: ad-m/github-push-action@master - with: - branch: gh-pages - directory: gh-pages - github_token: ${{ secrets.GITHUB_TOKEN }}