Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodeBuild with GitHub - only for specific directory

I am trying to set up automatic deployment for the Angular 2 app with AWS Pipeline, S3 and CodeBuild.

Following Andrés' tutorial I was able to connect CodeBuild the GitHub repo and the process works great.

However, our Angular app lives inside a subdirectory of the bigger repo.

Is there a way to specify a directory inside a repo, so that the build will only be triggered if the subdirectory changed?

Thanks a lot.

like image 209
Ilya Krasnov Avatar asked Jun 07 '17 10:06

Ilya Krasnov


2 Answers

If you are GitHub webhooks in CodeBuild, you now have a file_path option, which will allow you to trigger the build only when a specific file or directory is changed.

Documentation: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html#sample-github-pull-request-filter-webhook-events-console

like image 175
Subin Mathew Avatar answered Sep 21 '22 18:09

Subin Mathew


It doesn't look like you can just pull down a certain folder but the artifact for the build spec you can specify the directories that are used for the build.

For GitHub, for the optional Source version value, type a commit ID, a pull request ID, a branch name, or a tag name that corresponds to the version of the source code you want to build. If a pull request ID is specified, it must use the format pr/pull-request-ID (for example, pr/25). If a branch name is specified, the branch's HEAD commit ID will be used. If Source version is blank, the default branch's HEAD commit ID will be used.

http://docs.aws.amazon.com/codebuild/latest/userguide/run-build.html

artifacts Optional sequence. Represents information about where AWS CodeBuild can find the build output and how AWS CodeBuild will prepare it for uploading to the Amazon S3 output bucket. This sequence is not required if, for example, you are building and pushing a Docker image to Amazon ECR, or you are running unit tests on your source code but not building it. files: Required sequence. Represents the locations containing the build output artifacts in the build environment. Contains a sequence of scalars, with each scalar representing a separate location where AWS CodeBuild can find build output artifacts, relative to the original build location. Locations can include the following: A single file (for example, my-file.jar). A single file in a subdirectory (for example, my-subdirectory/my-file.jar or my-parent-subdirectory/my-subdirectory/my-file.jar). '/' represents all files recursively. my-subdirectory/ represents all files in a subdirectory named my-subdirectory. my-subdirectory//* represents all files recursively starting from a subdirectory named my-subdirectory.

http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html

like image 28
strongjz Avatar answered Sep 25 '22 18:09

strongjz