Automate with GitHub Actions
Trigger a cache warm automatically after each deployment using GitHub Actions.
Run a boost after every production deploy so your cache is warm before users arrive.
Prerequisites
- A boost already created via the API or dashboard
- Your site ID and boost ID
- An API key with
boosts:writescope
Workflow
Add this workflow to .github/workflows/warm-cache.yml in your repository:
name: Warm cache
on:
deployment_status:
jobs:
warm:
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
steps:
- name: Trigger CacheBoost run
run: |
curl -sf -X POST \
https://api.cache-boost.com/v1/sites/${{ vars.CACHEBOOST_SITE_ID }}/boosts/${{ vars.CACHEBOOST_BOOST_ID }}/run \
-H "Authorization: Bearer ${{ secrets.CACHEBOOST_API_KEY }}"
Configuration
Add the following to your repository:
| Name | Where | Value |
|---|---|---|
CACHEBOOST_API_KEY | Secrets | Your API key (cb_live_...) |
CACHEBOOST_SITE_ID | Variables | Your site ID |
CACHEBOOST_BOOST_ID | Variables | Your boost ID |
Go to Settings → Secrets and variables → Actions to add them.
Wait for the run to finish
If you want the workflow to wait until the run completes:
- name: Wait for run
run: |
RUN_ID=$(curl -sf -X POST \
https://api.cache-boost.com/v1/sites/${{ vars.CACHEBOOST_SITE_ID }}/boosts/${{ vars.CACHEBOOST_BOOST_ID }}/run \
-H "Authorization: Bearer ${{ secrets.CACHEBOOST_API_KEY }}" \
| jq -r '.id')
for i in $(seq 1 30); do
STATUS=$(curl -sf \
https://api.cache-boost.com/v1/runs/$RUN_ID \
-H "Authorization: Bearer ${{ secrets.CACHEBOOST_API_KEY }}" \
| jq -r '.status')
echo "Run status: $STATUS"
[ "$STATUS" = "done" ] && exit 0
[ "$STATUS" = "failed" ] && exit 1
sleep 10
done
echo "Timed out waiting for run"
exit 1
The poll loop above times out after 5 minutes (30 × 10s). Adjust seq 1 30 and sleep 10 to match your expected crawl duration.