Coder Social home page Coder Social logo

robin-aws / aws-codebuild-run-build Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-actions/aws-codebuild-run-build

0.0 1.0 0.0 60 KB

Run a AWS CodeBuild project as a step in a GitHub Actions workflow job.

License: Apache License 2.0

JavaScript 100.00%

aws-codebuild-run-build's Introduction

AWS CodeBuild Run Build for GitHub Actions

This action runs a AWS CodeBuild project as a step in a GitHub Actions workflow job.

The action builds the CodeBuild project, collects the build logs, and prints them as they are written. The user experience is the same as it would be if the logic were executed in the GitHub Actions job runner.

Usage

Inputs

This action offers three inputs that you can use to configure its behavior. The only required input is project-name.

  1. project-name (required) : The name of CodeBuild project you want to run.

  2. buildspec-override (optional) : The location (in this repository) of the buildspec file that CodeBuild requires. By default, the action uses the buildspec file location that you configured in the CodeBuild project.

  3. env-passthrough (optional) : A comma-separated list of the names of environment variables that the action passes from GitHub Actions to CodeBuild.

    The action passes these environment variables to CodeBuild along with any environment variables that have a github prefix.

    This list is often the same or a subset of the list of environment variables that you define for GitHub actions in the env property.

    Note: If you specify an environment variable with the same name as one defined in your CodeBuild project, the one defined here replaces the one in the CodeBuild project. For a list of CodeBuild environment variables, see

Outputs

  1. aws-build-id : The CodeBuild build ID of the build that the action ran.

Purpose

This action is designed to give you the power of GitHub Actions with options available in AWS CodeBuild for more CPU and memory, and access to other resources.

GitHub Actions provides a powerful system of event-based workflows, but the hosted job runners cannot exceed the defined computing and memory limits, and might prevent you from accessing resources that you need for your project.

AWS CodeBuild is a fully managed continuous integration service that can compile source code, run tests, and produce software packages that are ready to deploy. It supports more environment options than standard GitHub Actions, including a selection of powerful computing environments with additional memory.

Resources and Architecture

GitHub Actions job runners have 2 x86_64 CPU cores and 7 GB RAM.

This is enough for the most common activities, but some large or complex builds need more resources, and some builds need access to special CPU architectures or hardware.

CodeBuild compute types offer options including:

  • up to 72 x86_64 vCPUs
  • up to 255 GB RAM
  • up to 8 ARM64 vCPUs
  • GPU hardware devices

Access

Your workflow might require access to assets, configuration, or resources that are impossible, difficult, or simply expensive to access from GitHub's hosted job runners but are easy or cheap to access from CodeBuild.

Examples

These examples show how you can define a step in a workflow job. For more information about GitHub Actions workflow syntax, see the GitHub docs.

If your CodeBuild project is already configured the way you want it, the only CodeBuild Run input you need to provide is the project name.

- name: Start CodeBuild
  uses: aws-actions/aws-codebuild-run-project@v1
  with:
    project-name: CodeBuildProjectName

If you reuse a project in multiple jobs or repositories, you might want to provide a bit more configuration. For example, the following configuration specifies an alternate location for the buildspec file. It also tells AWS CodeBuild Run Build to send all of the environment variables defined in the env: list to CodeBuild. If any of these environment variables are defined in the CodeBuild project, this will overwrite them.

- name: Start CodeBuild
  uses: aws-actions/aws-codebuild-run-project@v1
  with:
    project-name: CodeBuildProjectName
    buildspec-override: path/to/buildspec.yaml
    env-passthrough: |
      custom,
      requester,
      event-name
  env:
    custom: my environment variable
    requester: ${{ github.actor }}
    event-name: ${{ github.event_name }}

Implementation Notes

What we did

We call the CodeBuild StartBuild API, checking out the commit that triggered the workflow.

The action waits for the build to complete while logging everything written to the build's Amazon CloudWatch Logs logstream. If the buildStatus value in the StartBuild response is SUCCEEDED, the action succeeds. Otherwise, it fails.

In the call to StartBuild, we pass in all GITHUB_ environment variables in the GitHub Actions environment, plus any environment variables that you specified in the evn-passthrough input value.

Regardless of the project configuration in CodeBuild or GitHub Actions, we always pass the following parameters and values to CodeBuild in the StartBuild API call.

CodeBuild value GitHub value
sourceVersion The commit that triggered the workflow
sourceTypeOverride The string 'GITHUB'
sourceLocationOverride The HTTPS git url for context.repo

What we did not do

This action intentionally does not let you specify every option in the CodeBuild::StartBuild API.

Because all GitHub Actions input values are passed through environment variables, they must be simple strings. This makes it difficult to pass complex structures as inputs.

Also, providing an input for every parameter in the StartBuild API would have made it much more difficult to use and maintain this tool. We would have to add many more inputs or require string values, while hoping that all supported configurations conformed to the environment variable length limits.

For this reason, and to simplify what we expect to be the most common use-cases, we chose to start with the simplest possible configuration. If you find that these options don't meet your needs, please open an issue to let us know.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE and NOTICE for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.