Deploy docs site to staging #428
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: Deploy docs site to staging | |
| on: | |
| push: | |
| branches: | |
| - staging | |
| workflow_run: | |
| workflows: ["Merge main into staging"] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| if: | | |
| github.event_name == 'push' || | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || | |
| github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out documentation repository | |
| uses: actions/checkout@v4 | |
| # Reclaim space + create a reserve for deterministic headroom | |
| - name: Free space + create reserve | |
| uses: ./.github/actions/free-disk-space | |
| with: | |
| remove_dotnet: "true" | |
| remove_android: "true" | |
| remove_haskell: "true" | |
| prune_docker: "true" | |
| apt_cleanup: "true" | |
| create_reserve_gb: "3" | |
| - name: Check out validmind-library repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: validmind/validmind-library | |
| path: site/_source/validmind-library | |
| token: ${{ secrets.DOCS_CI_RO_PAT }} | |
| - name: Check out installation repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: validmind/installation | |
| path: site/_source/installation | |
| token: ${{ secrets.DOCS_CI_RO_PAT }} | |
| sparse-checkout: | | |
| site/installation | |
| sparse-checkout-cone-mode: true | |
| - name: Check out release-notes repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: validmind/release-notes | |
| path: site/_source/release-notes | |
| token: ${{ secrets.DOCS_CI_RO_PAT }} | |
| sparse-checkout: | | |
| releases | |
| sparse-checkout-cone-mode: true | |
| - name: Check out backend repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: validmind/backend | |
| path: site/_source/backend | |
| token: ${{ secrets.DOCS_CI_RO_PAT }} | |
| sparse-checkout: | | |
| src/backend/templates/documentation/model_documentation | |
| sparse-checkout-cone-mode: true | |
| - name: Set up Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| with: | |
| version: ${{ vars.QUARTO_VERSION }} | |
| - name: Install Poetry | |
| run: | | |
| curl -sSL https://install.python-poetry.org | python3 - | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| - name: Generate Python library docs | |
| run: | | |
| cd site/_source/validmind-library | |
| make install && make quarto-docs | |
| cd ../../ | |
| rm -rf validmind | |
| mkdir -p validmind | |
| rsync -av --exclude '_build' --exclude 'templates' _source/validmind-library/docs/ validmind/ | |
| - name: Generate template schema docs | |
| run: | | |
| pip install json-schema-for-humans | |
| BACKEND_ROOT=site/_source/backend python scripts/generate_template_schema_docs.py | |
| - name: Populate installation | |
| run: cp -r site/_source/installation/site/installation site/installation | |
| - name: Populate release notes | |
| run: | | |
| cp -r site/_source/release-notes/releases site | |
| rm -f site/releases/backend-releases.qmd site/releases/cmvm-releases.qmd | |
| - name: Render staging docs site | |
| run: | | |
| cd site | |
| quarto render --profile staging &> render_errors.log || { | |
| echo "Quarto render failed immediately"; | |
| cat render_errors.log; | |
| exit 1; | |
| } | |
| make generate-sitemap | |
| - name: Add robots.txt for staging | |
| run: cp site/environments/robots-staging.txt site/_site/robots.txt | |
| # Staging bucket is in us-west-2 | |
| - name: Configure AWS credentials | |
| run: aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }} && aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }} && aws configure set default.region us-west-2 | |
| - name: Deploy docs staging site | |
| run: aws s3 sync site/_site s3://validmind-docs-staging/site --delete --exclude "installation/helm-repo/*" --exclude "pr_previews/*" --exclude "llm/*" && aws cloudfront create-invalidation --distribution-id ESWVTZYFL873V --paths "/*" --no-cli-pager | |
| # Release headroom and shrink before final lightweight steps & post-job | |
| - name: Release reserve & shrink | |
| if: always() | |
| uses: ./.github/actions/free-disk-space | |
| with: | |
| release_reserve: "true" | |
| remove_paths: | | |
| site/_source/installation | |
| site/_source/release-notes | |
| site/_source/backend | |
| site/render_errors.log | |
| site/_freeze | |
| dev.env | |
| valid.env | |
| - name: Final disk usage | |
| if: always() | |
| run: df -hT / |