How to Schedule CI at Low-Carbon Times
The same job emits less carbon when it runs while the grid is powered by more renewables.
Grid carbon intensity swings through the day as solar and wind rise and fall. For jobs that do not need to run now, a carbon signal (from services such as WattTime or Electricity Maps) lets you defer them to a cleaner window. This helps only for genuinely deferrable work.
Steps
- Identify jobs that are deferrable (nightly suites, batch reports, cache warming).
- Query a carbon-intensity API for the runner region and gate on a threshold.
- Schedule a wide cron window and let the job run only when intensity is low.
Gate on carbon intensity
.github/workflows/carbon-aware.yml
on:
schedule:
- cron: '0 */2 * * *' # check every 2 hours
jobs:
batch:
runs-on: ubuntu-latest
steps:
- name: Check grid carbon intensity
run: |
INTENSITY=$(curl -s "https://api.example-carbon.org/intensity?zone=$REGION" | jq '.value')
if [ "$INTENSITY" -gt 250 ]; then
echo "Grid is carbon-heavy ($INTENSITY), deferring."
exit 0
fi
npm run batch:reportTradeoffs
- Only defer non-urgent work; never delay a job a developer is waiting on.
- The carbon win is real but modest per job; it compounds across many deferrable runs.
Related guides
How to Run CI in Lower-Carbon Cloud RegionsPlace self-hosted CI runners and deploys in cloud regions with a cleaner electricity grid, so the same comput…
How to Measure the Energy and Carbon of a CI RunEstimate the energy and carbon footprint of a GitHub Actions job with Eco-CI, so you can see which pipelines…