Skip to main content

Actions

Usage

on:
  push:
    branches: [main]
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up BuildCharts
        uses: buildcharts/setup-action@v1

      - name: Generate BuildCharts
        uses: buildcharts/generate-action@v1

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Docker build and test
        uses: docker/bake-action@v6
        with:
          files: .buildcharts/docker-bake.hcl
        env:
          VERSION: ${{ github.ref_name }}
          COMMIT: ${{ github.sha }}

Scaffolding

buildcharts init creates .github/workflows/buildcharts.yml when the Git remote in .git/config points to GitHub.

Enable caching

If you run builds frequently, configure a cache backend for BuildKit. On GitHub Actions, type=gha is a common choice. Example using docker/bake-action to set cache options on the generated _common target:
- name: Docker build and test
  uses: docker/bake-action@v6
  with:
    files: .buildcharts/docker-bake.hcl
    set: |
      _common.cache-from=type=gha,scope=buildcharts
      _common.cache-to=type=gha,scope=buildcharts,mode=max
  env:
    VERSION: ${{ github.ref_name }}
    COMMIT: ${{ github.sha }}
Read more about BuildKit cache backends and the GitHub Actions (gha) cache backend.

Add a build summary

buildcharts summary appends Markdown to GITHUB_STEP_SUMMARY when that environment variable is present. Add this step after Bake if you want a job summary:
- name: Build summary
  run: buildcharts summary

Notes

  • buildcharts/setup-action@v1 installs the CLI.
  • buildcharts/generate-action@v1 generates .buildcharts/docker-bake.hcl.
  • docker/bake-action@v6 runs the generated plan. Add your own set overrides if you want to configure cache backends.
Last modified on March 15, 2026