Continuous Integration (deployment pipeline) using GitHub

You don’t happen to have a template lying around (pipeline.yml) that does exactly what php-basic-pipeline does - building a docker image from source, pushing it into ECR and deploying it to the CloudFormation stack - EXCEPT taking the source from GitHub instead of using AWS CodeCommit?

I found examples for Pipelines with GitHub using CloudFormation (.yml) as well as for Pipelines with CodeCommit using CloudFormation (.yml) - and an example using ECR that relies on building the image locally…

Interestingly, the php-basic-pipeline example doesn’t actually use an AWS::CodePipeline but seems to be purely a AWS::CodeBuild::Project. No idea how to plug a AWS::CodePipeline::Webhook (for GitHub) into that… :confused:

I already have a shellscript which does build the image locally, tag and push it and then deploys the cloudformation template using the newest tag/version - all in one fell swoop. Maybe adding a git pull to that and making it operate inside it’s own single-served container would be the more sensible way of doing things? :thinking:

We don’t make use of CodePipeline to keep things simple.

But you should be able use GitHub as the source by changing:

Source:
  Location: !Sub 'https://git-codecommit.${AWS::Region}.amazonaws.com/v1/repos/${CodeCommitRepositoryName}'
 Type: CODECOMMIT

to: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html#cfn-codebuild-project-source-type

and you will need to add credentials with this resource: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-sourcecredential.html

Let me know if this works for you and feel free to share your solution.

And what about the Webhook?

The RepositoryChangedRule currently listens in to codecommit, if there was a change to the master branch. To my understanding this event then triggers the whole codebuild to be executed in the first place.

If I’m not mistaken, it would be required to use the github API to create a Webhook, so that it’s possible to listen in on GitHub push and merge events.

Just changing the Source wouldn’t suffice - or would it?

Creating such a Webhook seems to be what the AWS console is doing, if you try to create a codebuild project through the GUI. Sadly there doesn’t seem to be any way to download or look at the corresponding yml for anything created through the GUI. At least I couldn’t figure out any way to do that.

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

Looks like it is possible. I’m not saying it is easy or “rapid” :slight_smile: That’s why we integrate with CodeCommit in the book. Much simpler.

Okay… I guess I’ll be sticking with a deploy-script then, at least for the time being.

I’m brand-new to AWS, and I already find the stuff that’s easy to you to be slightly impenetrable. Maybe I’ll take another stab at it further down the line, but for now I really want to wrap things up. This already took way longer than I ever would have anticipated.

I’ll be keeping an eye on this here as well:

Thanks for all the help! :smiley:

I see. The last solution I can offer you is to push your git repo to GitHub and CodeCommit.
You can add a 2nd remote to your repo locally.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.