Giftbit / codepipeline-github-action

Trigger GitHub actions in AWS CodePipeline

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CodePipeline GitHub Action

Trigger GitHub actions in AWS CodePipeline

Usage

This is the source code for an AWS Lambda function that can be used as a CodePipeline step to create and optionally merge a GitHub pull request between branches. This is most useful as part of a continuous integration flow between a staging pipeline and a production pipeline.

To use this in your own CodePipeline you can build the project and upload it to your own S3 bucket, or you can reference the latest build at s3://lightrail-public-resources/cloudformation/codepipeline-github-action/2020-03-17.zip

This function uses the following environment variables:

  • GITHUB_REPO_OWNER
  • GITHUB_REPO
  • GITHUB_SOURCE_BRANCH
    • The GitHub branch to pull from (head).
  • GITHUB_DEST_BRANCH
    • The GitHub branch to pull to (base).
  • GITHUB_OAUTH
    • The github oauth token for the GitHub user to run the commands as. This value must be KMS encrypted and the lambda function must have permission to decrypt. See the example CloudFormation template linked below on how this is best configured.
  • AUTO_MERGE (optional)
    • If true automatically merge the created pull request.
  • PULL_REQUEST_MESSAGE (optional)
    • The message to apply to the pull request. Defaults to "Automatic pull request by CI".
  • MERGE_MESSAGE (optional)
    • The message to apply to the merge, if AUTO_MERGE is true. Defaults to "Automatic merge by CI".

Check out Giftbit/sam-scaffold for an example CloudFormation template that uses this function.

Development

The only external dependency is node >= 10. The source code is written in TypeScript.

From the command line npm install && npm run build to build the distribution zip file, which will be at dist/dist.zip.

About

Trigger GitHub actions in AWS CodePipeline

License:Apache License 2.0


Languages

Language:TypeScript 77.8%Language:JavaScript 22.2%