Skip to content

Latest commit

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

buildgraph-action

GitHub Actions composite action for BuildGraph — intelligent selective rebuild for Go monorepos.

The action runs buildgraph analyze to detect which services changed, uploads an impact report, then runs buildgraph generate to save a fresh baseline for the next run. All in one step.

Usage

jobs:
analyze:
runs-on: ubuntu-latestoutputs:
services: ${{ steps.bg.outputs.services }}has_changes: ${{ steps.bg.outputs.has_changes }}steps:
- uses: actions/checkout@v4with:
fetch-depth: 0
- name: Run BuildGraphid: bguses: bubunyo/buildgraph-action@v0.0.0-alphabuild:
needs: analyzeif: needs.analyze.outputs.has_changes == 'true' && needs.analyze.outputs.services != '[]'runs-on: ubuntu-lateststrategy:
fail-fast: falsematrix:
service: ${{ fromJson(needs.analyze.outputs.services) }}steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5with:
go-version-file: go.modcache: true
- name: Build ${{ matrix.service }}run: go build -o bin/${{ matrix.service }} ./${{ matrix.service }}/...
- name: Test ${{ matrix.service }}run: go test ./${{ matrix.service }}/...

Inputs

InputDescriptionDefault
versionBuildGraph version to install (e.g. v0.1.0). Use latest for the latest release, or source to build from the local checkout.latest
go-version-filePath to go.mod used to select the Go toolchaingo.mod
baseline-artifact-nameArtifact name used to persist the baseline between runsbuildgraph-baseline
baseline-retention-daysDays to retain the baseline artifact90
configPath to buildgraph.yaml (overrides default location)(empty)
baselinePath to the baseline file (overrides buildgraph.yaml)(empty)
working-directoryDirectory to run buildgraph from.

Outputs

OutputDescription
has_changes"true" if any functions changed, "false" otherwise
servicesJSON array of relative service paths to rebuild, e.g. ["services/service-a","services/service-b"]
impact-filePath to the impact.json report written by buildgraph analyze

Examples

Pin to a specific version

- uses: bubunyo/buildgraph-action@v1with:
version: v0.2.0

Monorepo with a custom config path

- uses: bubunyo/buildgraph-action@v1with:
config: infra/buildgraph.yaml

Services in a non-standard working directory

- uses: bubunyo/buildgraph-action@v1with:
working-directory: backend

Share the baseline across multiple workflows

If you run BuildGraph in more than one workflow, give each a unique artifact name so their baselines don't collide:

- uses: bubunyo/buildgraph-action@v1with:
baseline-artifact-name: buildgraph-baseline-${{ github.workflow }}

Read the impact report in a later step

- name: Run BuildGraphid: bguses: bubunyo/buildgraph-action@v1
- name: Print affected servicesrun: cat ${{ steps.bg.outputs.impact-file }}

How it works

  1. Restores the baseline artifact from the previous run (continue-on-error: true so the first run is safe)
  2. Installs the buildgraph CLI via go install
  3. Runs buildgraph analyze and extracts has_changes and services into job outputs
  4. Uploads the impact report as an artifact (always, even on failure)
  5. Runs buildgraph generate to write a fresh baseline
  6. Uploads the new baseline artifact for the next run

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors