Lambda => CodeBuild = lambuild
lambuild
empowers AWS CodeBuild whose source provider is GITHUB
.
Instead of AWS CodeBuild's GitHub webhook events support,
lambuild
triggers build with GitHub Webhook, Amazon API Gateway, and AWS Lambda to provide the following powerful features.
- Multiple buildspec files
- Conditional builds
- Change CodeBuild Project conditionally
- Custom Environment Variables with GitHub Webhook Event and associated Pull Request
- Override Build Configuration like
image
in buildspec - Run multiple builds based on the same buildspec without Batch Build
- Run Batch Build's each build conditionally
- etc
- Getting Started
- Configuration
- Expression
- Error Notification
- Practice
GitHub Actions supports multiple workflow files in .github/workflows
directory.
Like GitHub Actions, lambuild
supports multiple buildspec files.
e.g.
version: 0.2
lambuild:
if: 'event.Headers.Event == "pull_request"'
build-status-context: "foo ({{.event.Headers.Event}})"
phases:
build:
commands:
- "echo foo"
e.g.
version: 0.2
lambuild:
env:
variables:
LAMBUILD_WEBHOOK_BODY: "event.Body"
LAMBUILD_WEBHOOK_EVENT: "event.Headers.Event"
LAMBUILD_WEBHOOK_DELIVERY: "event.Headers.Delivery"
LAMBUILD_HEAD_COMMIT_MSG: "getCommitMessage()"
phases:
build:
commands:
- 'echo $LAMBUILD_HEAD_COMMIT_MSG'
e.g.
version: 0.2
lambuild:
build-status-context: "foo ({{.event.Headers.Event}})"
image: aws/codebuild/standard:5.0
compute-type: BUILD_GENERAL1_SMALL
phases:
build:
commands:
- "echo foo"
e.g.
version: 0.2
lambuild:
env:
variables:
NAME: "item.name"
items:
- image: aws/codebuild/standard:5.0
param:
name: foo
- param:
name: bar
phases:
build:
commands:
- "echo NAME: $NAME"
Maybe you prefer this feature rather than Batch Build, because
- It takes time to run Batch Build
- Batch Build is a little inconvenient
e.g.
version: 0.2
batch:
build-list:
- identifier: foo
buildspec: foo/buildspec.yaml
if: 'any(getPRFileNames(), {# startsWith "foo/"})'
- identifier: renovate
buildspec: buildspec/renovate.yaml
if: 'any(getPRFileNames(), {# == "renovate.json"})'
User = (push, pull_request) => GitHub = (webhook) => API Gateway => Lambda => CodeBuild
This image is created with diagrams.net
- Lambda Functions is called via GitHub Webhook
- Request is filtered with hook configuration
- Configuration file is downloaded from the source repository
- buildspec is generated
- Build or Batch Build is run