Aspen

Estimate the energy use, carbon emissions and water consumption of your GitHub Actions, for one repository or a whole organisation.

CI CO2eq badge of the Aspen repository CI CO2eq billing badge of the Aspen repository

Add it to a workflow Read the methodology

What Aspen does

CI runs in data centres, and most GitHub hosted runners are in the US, where the grid still relies heavily on fossil fuels. Free minutes cost you nothing, but the electricity they use still emits carbon and consumes water.

Aspen takes the minutes your workflows ran on each type of runner, plus the storage they used, and turns them into three figures:

It writes them to a JSON report, a markdown summary in the job page (totals per repository, per workflow and per runner) and an optional badge for your README.

Aspen estimates from durations and runner types; it does not measure energy on the runner. For measured figures per step, look at eco-ci-energy-estimation.

Two ways to get the data

Aspen can read the usage from two sources. Both cover the same period, the last 30 days by default, so their figures can be compared.

jobs default

Reads the jobs of this repository's workflow runs through the Actions API.

  • Works with the built-in GITHUB_TOKEN, no secret to set up
  • Breaks the emissions down per workflow file
  • Durations are rounded up to whole minutes and the runner type is inferred from labels such as ubuntu-latest
  • Storage, self hosted and larger runners are not estimated

Start here. The badge is silver.

billing

Reads the organisation's billing report, the data GitHub invoices.

  • Minutes as billed and runner types from the billing SKU, so it is the more precise of the two
  • Includes Actions and Packages storage
  • No per workflow breakdown, as the billing API does not expose it
  • Needs an organisation token with Administration (read), which can see the billing of every repository

In a workflow, the report is filtered to the current repository. Run the command line tool to cover the whole organisation. The badge is gold.

Add it to a workflow

Save this as .github/workflows/carbon.yml. It runs every Monday, adds the summary to the job page, publishes the badge to a badges branch and keeps the JSON report as an artifact. The action downloads a prebuilt binary and checks its SHA-256 checksum, so there is no build step.

name: Carbon estimate

on:
  schedule:
    - cron: '0 6 * * 1'
  workflow_dispatch:

permissions:
  actions: read
  contents: write # to publish the badge on the `badges` branch

jobs:
  estimate:
    runs-on: ubuntu-latest
    steps:
      - uses: DigitalPebble/aspen@v1
        id: aspen
        with:
          publish_badge: true
      - uses: actions/upload-artifact@v4
        with:
          name: carbon-estimate
          path: ${{ steps.aspen.outputs.report-path }}

To use the billing source instead, pass an organisation token stored as a secret:

      - uses: DigitalPebble/aspen@v1
        with:
          source: billing
          github_token: ${{ secrets.ORG_BILLING_TOKEN }}
          publish_badge: true
          badge_path: badge-billing.json

The billing token can read the billing data of the whole organisation, including private repositories. Read the security considerations before using it, especially in a public repository.

All the inputs and outputs of the action are listed in the README.

Show a badge

With publish_badge: true, the action commits a shields.io endpoint file with the emissions over the period to the badges branch. Add it to your README, replacing OWNER/REPO with your repository:

[![CI CO2eq](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/OWNER/REPO/badges/badge.json)](https://aspen.digitalpebble.com/)

This is what it looks like for Aspen itself, with the jobs source then the billing one:

CI CO2eq badge, jobs source CI CO2eq badge, billing source

The badge only works for public repositories, since shields.io cannot read a branch of a private one.

Bringing the numbers down

The methodology explains where every figure comes from and what Aspen does not estimate.