简体   繁体   中英

How to copy github code to s3 bucket using only aws codebuild service?

I want to copy a latest code of gitHub into amazon s3 bucket with the help of only code build service.

I know it's pretty much straight forward to do using codepipeline and codedeploy service. But I am more interested to see how its doable only with the codebuild service.

At the moment, I do not have any kind of java/scala/node.js code in githib repository and also do not want to execute compile,run or test the code. I just simply looking to copy files from github to s3 bucket when there is PUSH event occured.

Please guide me,how to configure codebuild service for this use case.

Please share your thoughts and links with respect to this problem.

Thanks in advance.

I have followed below links to achieve this task.

https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-create-build-project-console.html

I managed to copy the github latest code to s3 bucket by specifying below command to the buildspec file.

Note : Initially, I was under impression that I will need to configure aws cli but that's not the case here. It's already been configured within codebuild environment.

buildpsec file在此处输入图像描述

Note : Make sure you have added enough permission(ie s3 read and write) to the codebuild default service role as below. 在此处输入图像描述

Please take a look on this docs:

CodeBuild - GitHub webhooks

CodeBuild Artifacts

The main idea:

You can create webhook from GitHub to CodeBuild. Every PUSH in GitHub it will start a CodeBuild container. This container get the artifacts (repository).

In the CodeBuild itself you already have access to the artifacts so for example you can use boto3 (Python)/aws-cli to interact with s3 bucket and upload the artifacts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM