Skip to content

Publish to another host

Publish the viewer from any CI to any static host, such as an S3-style bucket, Netlify or Cloudflare Pages.

Set fetch-depth: 0 on GitHub, or GIT_DEPTH: 0 on GitLab. The site builds past Revisions from git.

Restore .archidocs/cache/ from your CI cache. Key it by the Workspace Bundle’s schemaVersion, which this prints:

Terminal window
archidocs version --format json
{"version":"1.2.0","schemaVersion":1}

Run both, and stop if the check fails, so the last good site stays up:

Terminal window
archidocs check
archidocs build --out site
0 errors, 0 warnings
Wrote the site to site

Then save .archidocs/cache/ to your CI cache.

Upload site/ on every push to the default branch and on every tag. The site uses relative URLs and hash routing, so it works under any base path with no rewrites.

The headers are optional. Set them, so readers get each new deploy at once:

Path Cache-Control
bundles/<sha>.json public, max-age=31536000, immutable
bundles/index.json no-cache
workspace.bundle.json no-cache
site.json no-cache
index.html no-cache

Upload the past Bundles first and the index last, so a reader never sees an index naming a Bundle that isn’t there yet:

Terminal window
aws s3 sync site/bundles/ "s3://$BUCKET/bundles/" --delete --exclude index.json \
--cache-control "public, max-age=31536000, immutable"
aws s3 sync site/ "s3://$BUCKET/" --delete --exclude "bundles/*" --exclude index.html --exclude workspace.bundle.json --exclude site.json
aws s3 cp site/workspace.bundle.json "s3://$BUCKET/" --cache-control no-cache
aws s3 cp site/site.json "s3://$BUCKET/" --cache-control no-cache
aws s3 cp site/index.html "s3://$BUCKET/" --cache-control no-cache
aws s3 cp site/bundles/index.json "s3://$BUCKET/bundles/" --cache-control no-cache

Netlify applies every matching rule in _headers, so give each Bundle a rule of its own. A /bundles/* rule would also match index.json. Write the file into the site before deploying:

Terminal window
{
printf '/index.html\n Cache-Control: no-cache\n'
printf '/workspace.bundle.json\n Cache-Control: no-cache\n'
printf '/site.json\n Cache-Control: no-cache\n'
printf '/bundles/index.json\n Cache-Control: no-cache\n'
for f in site/bundles/*.json; do
[ "$(basename "$f")" = index.json ] && continue
printf '/bundles/%s\n Cache-Control: public, max-age=31536000, immutable\n' "$(basename "$f")"
done
} > site/_headers
netlify deploy --prod --dir site

Cloudflare Pages joins the values of matching rules, so detach the general rule’s header for the index with !:

Terminal window
cat > site/_headers <<'EOF'
/bundles/*
Cache-Control: public, max-age=31536000, immutable
/bundles/index.json
! Cache-Control
Cache-Control: no-cache
/workspace.bundle.json
Cache-Control: no-cache
/site.json
Cache-Control: no-cache
/index.html
Cache-Control: no-cache
EOF
wrangler pages deploy site --project-name <project>

Open the site’s URL: the viewer starts on the C1 Landscape. In the browser’s developer tools, the response for bundles/index.json has Cache-Control: no-cache.

If the viewer shows only the latest Revision, the CI checkout is shallow. Check out the full history, as in step 1.

If a new deploy doesn’t show until a hard reload, index.html, workspace.bundle.json or bundles/index.json is cached. Set no-cache on all three.

Documents the beta branch at cd98671, ahead of the latest release, v1.4.0.