Skip to content

Deploy content via CI/CD pipelines

One of the most common use-cases for Quant is having a CI/CD pipeline trigger a build and deploy action from a static site generator, or other custom solution that generates or compiles content to publish to the edge.

This guide will configure a CI pipeline to build and deploy development & production branches for an example Astro project to the Quant static edge using GitHub Actions.

This is the full code example responsible for building, deploying, and clearing the caches. For those familiar with GitHub actions already the portion responsible for deployment and cache clearing is highlighted, you can simply copy and tweak to suit your project.

We will break it down in further detail below.

.github/workflows/deploy.yml
name: "Deploy Astro project to QuantCDN"
on:
push:
branches:
- develop
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Set environment for branch
run: |
echo "QUANT_CUSTOMER=quant-demo" >> "$GITHUB_ENV"
if [[ $GITHUB_REF == 'refs/heads/main' ]]; then
echo "QUANT_PROJECT=astro-example-prod" >> "$GITHUB_ENV"
echo "QUANT_TOKEN=${{ secrets.QUANT_TOKEN_PRODUCTION }}" >> "$GITHUB_ENV"
else
echo "QUANT_PROJECT=astro-example-dev" >> "$GITHUB_ENV"
echo "QUANT_TOKEN=${{ secrets.QUANT_TOKEN_DEV }}" >> "$GITHUB_ENV"
fi
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Restore revision log
uses: actions/cache@v5
with:
path: .quant-revision
key: quant-revision-${{ github.ref }}-${{ github.run_id }}
restore-keys: |
quant-revision-${{ github.ref }}-
- name: Build site
run: npm run build
- name: Deploy to QuantCDN
uses: quantcdn/deploy-action@v6
with:
customer: "${{ env.QUANT_CUSTOMER }}"
project: "${{ env.QUANT_PROJECT }}"
token: "${{ env.QUANT_TOKEN }}"
dir: dist
skip-purge: true
revision-log: .quant-revision
- name: Purge CDN cache
uses: quantcdn/purge-action@v6
with:
customer: "${{ env.QUANT_CUSTOMER }}"
project: "${{ env.QUANT_PROJECT }}"
token: "${{ env.QUANT_TOKEN }}"
url_pattern: "/*"

Your QuantCDN project token is used to connect to the Quant API when content is pushed up. This token should never be shared or made publicly available, so you will want to define this value as a GitHub secret.

To do this, navigate to your projects settings screen in GitHub and add the value in the “Secrets and Variables” > “Actions” section as a repository secret.

In our example we are building both a development and production version of our Astro site, so we will set both QUANT_TOKEN_PRODUCTION and QUANT_TOKEN_DEV.

You can retrieve the project tokens from the Integrations section of the Quant Dashboard.

Setting the environment variables (optional)

Section titled “Setting the environment variables (optional)”

At the beginning of the deployment process we are setting environment variables for the QUANT_PROJECT and QUANT_TOKEN values depending on the branch.

If you are only interested in deploying a single branch you can skip this step, as the values can be input directly into the deployment stage.

- name: Set environment for branch
run: |
echo "QUANT_CUSTOMER=quant-demo" >> "$GITHUB_ENV"
if [[ $GITHUB_REF == 'refs/heads/master' ]]; then
echo "QUANT_PROJECT=astro-example-prod" >> "$GITHUB_ENV"
echo "QUANT_TOKEN=${{ secrets.QUANT_TOKEN_PRODUCTION }}" >> "$GITHUB_ENV"
else
echo "QUANT_PROJECT=astro-example-dev" >> "$GITHUB_ENV"
echo "QUANT_TOKEN=${{ secrets.QUANT_TOKEN_DEV }}" >> "$GITHUB_ENV"
fi

The deployment itself uses our GitHub Action.

This action can optionally track the previous deployment state, including all of the md5 hashes for assets in the compiled build. This allows for must faster ongoing deployments, as assets that have not changed since the last build can be skipped.

- name: Deploy to QuantCDN
uses: quantcdn/deploy-action@v6
with:
customer: "${{ env.QUANT_CUSTOMER }}"
project: "${{ env.QUANT_PROJECT }}"
token: "${{ env.QUANT_TOKEN }}"
dir: dist
skip-purge: true
revision-log: .quant-revision

In this example we are setting the dir value to the directory of our compiled Astro build.

We are also setting the skip-purge value to true which will skip purging CDN caches during the actual deployment step. We will issue a bulk purge in the next step.

Clearing caches after the deployment completes

Section titled “Clearing caches after the deployment completes”

We use our cache purge GitHub Action here.

- name: Purge CDN cache
uses: quantcdn/purge-action@v6
with:
customer: "${{ env.QUANT_CUSTOMER }}"
project: "${{ env.QUANT_PROJECT }}"
token: "${{ env.QUANT_TOKEN }}"
url_pattern: "/*"

This one is fairly self explanatory, we are purging the entire cache for the project (/*) which will ensure the CDN caches are reset at the end of the deployment.

The setup-node action has built-in support for caching the npm download cache. Add cache: 'npm' to skip re-downloading packages that haven’t changed:

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'

The Quant revision log tracks the md5 hashes of all assets deployed in the previous build, so unchanged assets can be skipped on subsequent deploys.

This is an optional performance optimization, but it is recommended to ensure your pipeline runs as efficiently as possible.

- name: Restore revision log
uses: actions/cache@v5
with:
path: .quant-revision
key: quant-revision-${{ github.ref }}-${{ github.run_id }}
restore-keys: |
quant-revision-${{ github.ref }}-

The cache is scoped per branch using github.ref, so production and staging deployments maintain separate revision logs. The github.run_id suffix ensures a new cache entry is saved after every deploy, while restore-keys restores the most recent previous entry.