4 ms·
We actually just implemented something like this. Our entire environment is AWS CodeBuild, CodePipeline, and Lambda-based, but the process would be similar for
by cddotdotslash 7y ago
We actually just implemented something like this. Our entire environment is AWS CodeBuild, CodePipeline, and Lambda-based, but the process would be similar for more traditional environments:
1. Developer creates a PR. To be mergeable, it must pass code review, be based on master, and be up-to-date with master (GitHub recently made this really easy by adding a one-click button to resync master into the PR).
2. Each commit runs a build system that installs dependencies, runs tests, and ZIPs the final code to an S3 bucket.
3. Once the developer is ready to deploy, and the PR passes the above checks, they type "/deploy" as a GitHub comment.
3. A Lambda function performs validation and then updates our dev Lambda functions with the ZIP file from S3. Once complete, it leaves a comment on the PR with a link to the dev site to review.
4. The developer can now comment "/approve" or "/reject". Reject reverts the last Lambda deploy in dev. Approve moves the code to stage.
5. The above steps repeat for stage --> prod.
6. Once the code is in prod, the developer must approve or reject. If rejected, the Lambdas are reverted all the way back through dev. If approved, the PR is merged by the bot (we have some additional automation here, such as monitoring CloudWatch metrics for API stability, end-to-end tests, etc).
TL;DR - Don't merge PRs until the code is in production and reviewed. If a rollback is needed afterwards, create a rollback (roll-forward) PR and repeat.
- jacobkg 7y ago“GitHub recently made this really easy by adding a one-click button to resync master into the PR” I’m trying to find this feature but my google-fu is failing me. Can you link to an announcement or doc page for this?
- cddotdotslash 7y agoI can't find any announcements about it, but you can try it out: open a PR based on master, then push a separate commit (or merge a different PR) to master and return to your original PR. If you scroll down, there will be a box saying the base branch is out of date and a button asking to resync with master. If you click it, they will merge the master branch into your PR. I'm not sure if there are specific settings required for this to work. For example, we have the master branch protected and require the status checks to pass and the PR to be up to date before it can be merged.