Skip to content

Publishing the documentation site

The Zensical build produces a static site in site/. The publication script uploads that directory to an existing S3 origin and invalidates the associated CloudFront distribution. The public site is https://sandbox-loom-documentation.dogfooding.shop/.

Infrastructure boundary

Provision the following separately through reviewed infrastructure changes:

  • an S3 bucket dedicated to the documentation site;
  • a CloudFront distribution whose origin is that bucket;
  • a CloudFront Origin Access Control (OAC) using SigV4;
  • an S3 bucket policy granting s3:GetObject only to that distribution;
  • the desired aliases, ACM certificate, TLS policy, logging, and response headers policy.

The publish script does not create buckets, distributions, policies, or credentials. It verifies the selected distribution references the selected S3 bucket before uploading content and can optionally verify the active AWS account with AWS_ACCOUNT_ID.

Build and publish

From the repository root:

./.venv-zensical/bin/zensical build --clean --strict

export AWS_PROFILE="your-publishing-profile"
export AWS_REGION="us-east-1"
export SITE_S3_BUCKET="your-documentation-bucket"
export CLOUDFRONT_DISTRIBUTION_ID="E1234567890ABC"

./scripts/publish-site-to-cloudfront.sh

The AWS CLI uses the active profile or credential environment configured by the operator. The script never prints credential values. It checks the caller identity, confirms site/index.html exists, verifies that the CloudFront distribution has an origin matching SITE_S3_BUCKET, synchronizes the site with stale-object deletion, reapplies revalidation headers to HTML entry points, and waits for the invalidation to complete.

GitHub Actions deployment

The checked-in .github/workflows/docs.yml currently runs only when manually dispatched. The deploy job is enabled for that dispatch, so a dispatch with valid publishing configuration builds and publishes the site. It does not currently build on pull requests or pushes. Configure the documentation-production GitHub environment and these repository or environment variables:

Treat a manual dispatch as a publish operation, not as a build-only check. To change the trigger or add a build-only pull-request path, update and review the workflow's trigger and deploy-job condition together.

  • AWS_ROLE_ARN — IAM role trusted for this repository's GitHub OIDC identity;
  • AWS_REGION — use us-east-1 for the CloudFront API and role session;
  • SITE_S3_REGION — the region containing the S3 origin bucket;
  • AWS_ACCOUNT_ID — expected account ID checked by the publisher;
  • SITE_S3_BUCKET — the private S3 origin bucket;
  • CLOUDFRONT_DISTRIBUTION_ID — the public distribution serving the site.

The deploy job receives id-token: write and assumes the role through OIDC; do not store long-lived AWS access keys in GitHub secrets. Restrict the IAM trust policy to this repository and the documentation-production environment, and scope its permissions to the one site bucket and distribution. The job downloads the artifact produced by the strict build and runs the same publisher script used locally.

For a non-blocking deployment, set:

export WAIT_FOR_CLOUDFRONT_INVALIDATION=0

To invalidate a narrower path during an emergency cache refresh:

export CLOUDFRONT_INVALIDATION_PATH="/index.html"

Required IAM actions

The publishing identity should be scoped to the specific bucket and distribution. It needs, at minimum:

  • s3:ListBucket on the documentation bucket;
  • s3:PutObject, s3:DeleteObject, and s3:GetObject on its object prefix;
  • cloudfront:GetDistribution and cloudfront:GetDistributionConfig for preflight verification;
  • cloudfront:CreateInvalidation for the selected distribution; and
  • sts:GetCallerIdentity for identity verification.

The S3 bucket should remain private; CloudFront, not the S3 website endpoint, should be the public delivery boundary.