Merge pull request #1143 from MPAS-Dev/dependabot/github_actions/pref… #107
This file contains hidden or 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: CI/CD Release Workflow | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| release: | |
| types: [published] | |
| env: | |
| PYTHON_VERSION: "3.14" | |
| jobs: | |
| publish-docs: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 0 | |
| - name: Set up Pixi | |
| uses: prefix-dev/setup-pixi@v0.9.5 | |
| with: | |
| environments: py314 | |
| - name: Build Sphinx Docs | |
| run: | | |
| set -e | |
| git config --global url."https://github.com/".insteadOf "git@github.com:" | |
| pixi run -e py314 python -m pip check | |
| pixi run -e py314 mpas_analysis sync diags --help | |
| pixi run -e py314 bash -lc ' | |
| cd docs | |
| DOCS_VERSION=${{ github.ref_name }} make versioned-html | |
| ' | |
| - name: Copy Docs and Commit | |
| run: | | |
| set -e | |
| pixi run -e py314 bash -lc ' | |
| cd docs | |
| # gh-pages branch must already exist | |
| git clone https://github.com/MPAS-Dev/MPAS-Analysis.git --branch gh-pages --single-branch gh-pages | |
| # Only replace docs in a directory with the destination branch name with latest changes. Docs for | |
| # releases should be untouched. | |
| rm -rf gh-pages/${{ github.ref_name }} | |
| # do not clobber existing release versions if they were updated manually | |
| cp -r _build/html/${{ github.ref_name }} gh-pages/ | |
| mkdir -p gh-pages/shared | |
| cp shared/version-switcher.js gh-pages/shared/version-switcher.js | |
| # Update the list of versions with all versions in the gh-pages directory. | |
| python generate_versions_json.py | |
| cd gh-pages | |
| touch .nojekyll | |
| printf "<meta http-equiv=\"refresh\" content=\"0; url=./develop/index.html\" />" > index.html | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add . | |
| git commit -m "Update documentation" -a || true | |
| ' | |
| - name: Push Changes | |
| uses: ad-m/github-push-action@master | |
| with: | |
| branch: gh-pages | |
| directory: docs/gh-pages | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| force: true |