Skip to main content

Reusable Workflows

The devex-reusable-workflows repository provides a library of GitHub Actions reusable workflows and composite actions used across all Foundations repositories for CI/CD.

Reusable Workflows

14 reusable workflows are available under .github/workflows/:

WorkflowPurposeVersion
terraform-pr.ymlTerraform plan on pull requests (mock credentials)v0.x
terraform-ci.ymlTerraform apply on merge to main/env branches (real credentials)v0.3.0
docker-pr.ymlDocker build and test on pull requestsv0.x
docker-ci.ymlDocker build and promote on mergev0.x
docker-release.ymlDocker publish release imagesv0.x
semantic-release.ymlAutomated semantic versioning and releasev0.x
generate-backends.ymlGenerate Terraform backend configurationsv0.x
make.ymlRun Makefile targetsv0.x
tfc-apply.ymlTerraform Cloud apply workflowv0.x
tfc-plan.ymlTerraform Cloud plan workflowv0.x
release-please.ymlGoogle release-please for changelog generationv0.x
release-please-pr.ymlCreate release-please pull requestsv0.x
release-publish.ymlPublish release artifactsv0.x
backstage-notify.ymlNotify Backstage of pipeline statusv0.x

How to Reference Workflows

Call a reusable workflow from any repository using the standard GitHub Actions uses syntax:

jobs:
terraform-plan:
uses: badal-io/devex-reusable-workflows/.github/workflows/terraform-pr.yml@workflows/terraform-pr/v0.3.0
with:
working_directory: terraform/
secrets: inherit

The @ reference uses the versioning tag format described in Versioning Scheme.

Composite Actions

22+ composite actions are organized by category:

Docker Actions (actions/docker/)

ActionPurpose
buildBuild Docker images with caching
pushPush images to a container registry
promotePromote images between registries/tags
scanScan images for vulnerabilities

GitHub Actions (actions/github/)

ActionPurpose
create-prCreate pull requests programmatically
comment-prAdd comments to pull requests
notifySend notifications (Backstage, Slack)
setup-gitConfigure git identity for CI commits

Terraform Actions (actions/terraform/)

ActionPurpose
setupInstall and configure Terraform CLI
initRun terraform init with backend config
planRun terraform plan with output formatting
applyRun terraform apply with safety checks
fmt-checkCheck Terraform formatting
validateRun terraform validate
mock-credentialsGenerate mock GCP credentials for PR plans

Release-Please Actions (actions/release-please/)

ActionPurpose
setupConfigure release-please
create-releaseCreate GitHub releases with changelogs
bump-versionDetermine next version from commits

Terraform Workflow Pattern

Terraform CI/CD follows a two-phase pattern that separates planning from applying:

PR Phase (terraform-pr)

Pull Request opened/updated
└── terraform-pr workflow
├── terraform init
├── terraform fmt -check
├── terraform validate
├── Mock GCP credentials (WIF with limited permissions)
├── terraform plan
└── Post plan output as PR comment
  • Uses mock credentials generated via the mock-credentials composite action
  • Plans are informational only; no changes are applied
  • Plan output is posted as a PR comment for review
  • Runs on every push to the PR branch

CI Phase (terraform-ci)

Merge to main (or env branch)
└── terraform-ci workflow
├── terraform init
├── Authenticate via WIF (real credentials)
├── terraform plan
├── terraform apply -auto-approve
└── Notify Backstage of completion
  • Uses real credentials via Workload Identity Federation
  • Applies changes automatically after merge
  • For environment-based branching, each branch triggers apply to its corresponding environment

Environment Mapping

Branching ModelBranchEnvironment
Trunk-basedmainAll environments (sequentially or parallel)
Environment-baseddevelopmentdevelopment
Environment-basednon-productionnon-production
Environment-basedproductionproduction

Docker Workflow Pattern

Docker CI/CD follows a three-phase pattern:

PR Phase (docker-pr)

Pull Request
└── docker-pr workflow
├── Docker build (no push)
├── Run tests in container
└── Vulnerability scan

CI Phase (docker-ci)

Merge to main
└── docker-ci workflow
├── Docker build
├── Push to dev/staging registry
└── Promote tag (if configured)

Release Phase (docker-release)

GitHub Release created
└── docker-release workflow
├── Docker build with release tag
├── Push to production registry
└── Sign image (if configured)

Release Management

Two release strategies are supported:

semantic-release

Uses semantic-release for automated versioning based on conventional commits:

  • fix: commits trigger patch releases
  • feat: commits trigger minor releases
  • BREAKING CHANGE triggers major releases
  • Automatically generates changelogs and GitHub releases

release-please

Uses Google's release-please for release management:

  • Creates and maintains release PRs with changelogs
  • Merging the release PR triggers the actual release
  • Supports monorepo configurations with per-path releases

Versioning Scheme

Workflows and actions use independent semantic versioning with path-based tags:

{type}/{path}/v{major}.{minor}.{patch}

Examples:

TagDescription
workflows/terraform-ci/v0.3.0Terraform CI workflow version 0.3.0
workflows/docker-pr/v0.1.0Docker PR workflow version 0.1.0
actions/terraform/plan/v1.0.0Terraform plan action version 1.0.0

This allows each workflow and action to be versioned independently. Consumers pin to specific versions and upgrade deliberately.

Design Principles

The reusable workflow library follows these principles:

  1. Separation of concerns: Workflows handle orchestration; composite actions handle individual steps. This allows mixing and matching actions across workflows.

  2. Credential isolation: PR workflows never receive real cloud credentials. Mock credentials allow terraform plan to succeed syntactically without granting any actual access.

  3. Version independence: Each workflow and action is versioned separately. A breaking change in one workflow does not force upgrades of others.

  4. Convention over configuration: Workflows assume standard directory layouts (terraform/, Dockerfile) and naming conventions. Overrides are available via input parameters.

  5. Transparency: All plan outputs, build logs, and scan results are posted as PR comments for review before merge.

  6. Composability: Workflows can be combined. For example, a repository might use terraform-pr + terraform-ci for infrastructure and docker-pr + docker-ci + docker-release for application code, all in the same repo.