Publish to another host
Publish the viewer from any CI to any static host, such as an S3-style bucket, Netlify or Cloudflare Pages.
Before you start
Section titled “Before you start”archidocs checkpasses on the Workspace. See the Quick start.- Your CI can install the CLI and upload files to the host. On GitHub or GitLab Pages, use Publish to GitHub Pages or Publish to GitLab Pages instead.
1. Check out the full history
Section titled “1. Check out the full history”Set fetch-depth: 0 on GitHub, or GIT_DEPTH: 0 on GitLab. The site builds past Revisions from git.
2. Restore the history cache
Section titled “2. Restore the history cache”Restore .archidocs/cache/ from your CI cache. Key it by the Workspace Bundle’s schemaVersion, which this prints:
archidocs version --format json{"version":"1.2.0","schemaVersion":1}3. Check and build
Section titled “3. Check and build”Run both, and stop if the check fails, so the last good site stays up:
archidocs checkarchidocs build --out site0 errors, 0 warningsWrote the site to siteThen save .archidocs/cache/ to your CI cache.
4. Upload the site
Section titled “4. Upload the site”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 |
An S3-style bucket
Section titled “An S3-style bucket”Upload the past Bundles first and the index last, so a reader never sees an index naming a Bundle that isn’t there yet:
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.jsonaws s3 cp site/workspace.bundle.json "s3://$BUCKET/" --cache-control no-cacheaws s3 cp site/site.json "s3://$BUCKET/" --cache-control no-cacheaws s3 cp site/index.html "s3://$BUCKET/" --cache-control no-cacheaws s3 cp site/bundles/index.json "s3://$BUCKET/bundles/" --cache-control no-cacheNetlify
Section titled “Netlify”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:
{ 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/_headersnetlify deploy --prod --dir siteCloudflare Pages
Section titled “Cloudflare Pages”Cloudflare Pages joins the values of matching rules, so detach the general rule’s header for the index with !:
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-cacheEOFwrangler pages deploy site --project-name <project>Check it worked
Section titled “Check it worked”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 it didn’t
Section titled “If it didn’t”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.
Related
Section titled “Related”- Revisions and history
archidocs buildreference- Publish to GitHub Pages, which the Action does for you
Documents the beta branch at cd98671, ahead of the latest release, v1.4.0.