Skip to content

Deploy docs site to staging #413

Deploy docs site to staging

Deploy docs site to staging #413

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.RELEASE_NOTES_RO_PAT }}
- name: Check out installation repository
uses: actions/checkout@v4
with:
repository: validmind/installation
path: site/_source/installation
token: ${{ secrets.INSTALLATION_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.RELEASE_NOTES_RO_PAT }}
sparse-checkout: |
releases
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: 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/render_errors.log
site/_freeze
dev.env
valid.env
- name: Final disk usage
if: always()
run: df -hT /