lambuild

module
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2021 License: MIT

README

lambuild

Build Status Go Report Card GitHub last commit License

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.

Feature

Multiple buildspec files

GitHub Actions supports multiple workflow files in .github/workflows directory. Like GitHub Actions, lambuild supports multiple buildspec files.

Conditional builds

e.g.

version: 0.2
lambuild:
  if: 'event.Headers.Event == "pull_request"'
  build-status-context: "foo ({{.event.Headers.Event}})"
phases:
  build:
    commands:
      - "echo foo"
Custom Environment Variables with GitHub Webhook Event and associated Pull Request

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'
Override Build Configuration like image in buildspec

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"
Run multiple builds based on the same buildspec without Batch Build

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
Run Batch Build's each build conditionally

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"})'

Architecture

User = (push, pull_request) => GitHub = (webhook) => API Gateway => Lambda => CodeBuild

lambuild-architecture

This image is created with diagrams.net

How does it work?

  1. Lambda Functions is called via GitHub Webhook
  2. Request is filtered with hook configuration
  3. Configuration file is downloaded from the source repository
  4. buildspec is generated
  5. Build or Batch Build is run

Supported GitHub Events

LICENSE

MIT

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL