Cache rebuild triggers
Cache rebuild triggers provide instructions to RWX about how to rebuild your content-based cache. We use cache rebuild triggers to make the RWX cache even faster and more effective than it already is.
Defining a cache rebuild trigger
Like event triggers, cache triggers are defined in the on
section of your run definition.
Here's an example:
on:
cache-rebuild:
init:
commit-sha: ${{ event.git.sha }}
Because cache rebuilds may be triggered at any time, you should avoid running tasks that have meaningful side effects, such as deployment tasks or production migrations. You can use init parameters to prevent particular tasks from running. In the following example, only the build
task will run on a cache rebuild, but both tasks will run on pushes to main
:
on:
cache-rebuild:
init:
commit-sha: ${{ event.git.sha }}
deploy: false
github:
push:
if: ${{ event.git.branch == "main" }}
init:
commit-sha: ${{ event.git.sha }}
deploy: true
tasks:
- key: build
run: echo build
- key: deploy
if: ${{ init.deploy }}
run: echo deploy
You can also target specific tasks in a cache rebuild trigger if you cannot use init parameters to avoid running tasks with side effects. In this example too only the build
task (and any of its dependencies) will run on a cache rebuild:
on:
cache-rebuild:
target: [build]
init:
commit-sha: ${{ event.git.sha }}
tasks:
- key: build
run: echo build
- key: deploy
run: echo deploy
Cache rebuild timing
Cache rebuilds may be triggered from the RWX platform at any time. In general you can expect a cache rebuild to be triggered once per night in your organization, but a cache rebuild can also be triggered throughout the rest of day if we determine that your organization would benefit from a cache rebuild.