带 GitHub 的 AWS CodeBuild - 仅适用于特定目录

AWS CodeBuild with GitHub - only for specific directory

我正在尝试使用 AWS Pipeline、S3 和 CodeBuild 为 Angular 2 应用程序设置自动部署。

跟随 Andrés 的 tutorial,我能够将 CodeBuild 连接到 GitHub 存储库并且过程运行良好。

但是,我们的 Angular 应用位于更大的存储库的子目录中。

有没有办法在 repo 中指定一个目录,以便只有在子目录发生变化时才会触发构建?

非常感谢。

看起来您不能只下拉某个文件夹,但是构建规范的工件您可以指定用于构建的目录。

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

如果您是 CodeBuild 中的 GitHub webhook,您现在有一个 file_path 选项,它允许您仅在特定文件或目录更改时触发构建。

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