cerner / cerner.github.io

Cerner Engineering blog
https://engineering.cerner.com
15 stars 28 forks source link

Feature Branch Deploys #133

Closed alex-bezek closed 4 years ago

alex-bezek commented 4 years ago

As a contributor, I want branches to be auto deployed so i can preview my changes prior to merging, so that people can write blogs in markdown without having to run the site locally to preview changes, and so reviewers can see the most up to date changes without relying on old screenshots.

Design Proposal

There are many services and tools available that offer varying out of the box experiences to achieve this.

Other options:

Preferred Option:

From a hosting and deployment perspective, AWS Amplify offers almost the same full feature set as Netflify https://aws.amazon.com/amplify/ . To try it out, i implemented it using a fork of the repo https://github.com/alex-bezek/cerner.github.io. Because everything i wanted to do is covered in the free tier, i just used my own aws account for convenience. The steps i took were:

version: 0.1
frontend:
  phases:
    preBuild:
      commands:
        - apt-get update -y
        - apt-get install default-jdk -y
        - apt install python-pip -y
        - apt install python2.7 -y
        - apt-get install python-pygments -y
        - bundle install
    build:
      commands:
        - bundle exec rake generate
  artifacts:
    baseDirectory: public
    files:
      - '**/*'
  cache:
    paths: []

Outputs

Primary Branch deployed: https://source.df01c5fpiua30.amplifyapp.com/ Pull Request: https://github.com/alex-bezek/cerner.github.io/pull/1 PR Deploy: https://pr-1.df01c5fpiua30.amplifyapp.com/

Make it real

In order to use it in a production setting, there are some additional things we would want to do

Pricing

https://aws.amazon.com/amplify/console/pricing/

image

Because it's just managing static assets, the pricing is very reasonable. At 1000 free build minutes per month, and our current build taking only 7 minutes (which could be reduced much further with a custom container with packages pre-installed) we likely would never pass this (we would need over 140 builds in a month).

Future thoughts

While not in scope for this issue, amplify could be used to automate the deployment of the primary branch instead of using github pages. While it is probably less work to just setup a github action to deploy the source branch, it would be nice to only manage a single method of deployments. A couple of other minor benefits are

alex-bezek commented 4 years ago

We've discussed this amongst a few of us and amplify seems like a good fit, but we wanted to put this proposal out here to discuss more and see if there are any other opinions.

mjhenkes commented 4 years ago

Terra does this for free with heroku review apps: https://devcenter.heroku.com/articles/github-integration-review-apps

Which you stated above, but it's been working out for us.

alex-bezek commented 4 years ago

Thanks @mjhenkes . Looking at the free tier it does allow up to 5 team members which would probably be plenty for this group. Netfliy's issue was the free tier only allowed a single member.

Admittedly I'm a bit biased against heroku for deploying static sites since i'm used to using other static deployment tools like netlify and zeit. Heroku utilizes containers so my understanding is you have to build your statics and run them in a simple server so there are quirks like having to deal with those containers going to sleep and spinning back up when requested. Static site deployments have some minor other niceties like immutable deploys so you can compare the current vs the old deploys that never disappear.

These are pretty minor things though, especially with the amount it would be used for this repo, so if the fact that it's super easy to setup and the terra team uses it already, it might be worth considering more heavily.

alex-bezek commented 4 years ago

Another option we are talking about is having an internal fork and utilizing an internal bot that does internal branch deploys to jenkins workspaces. This would be a side-affect of solving this problem https://github.com/cerner/cerner.github.io/issues/135 that way

mjhenkes commented 4 years ago

I poked around at setting this up on heroku for you, but your version of ruby is way too old to build on heroku. You'd have to at a minimum do issue https://github.com/cerner/cerner.github.io/issues/108 before it would work.

cchesser commented 4 years ago

These changes have been applied to #136. We should be able to close this out once #136 is finished.

cchesser commented 4 years ago

Changes have been merged into source: 1a72b67a1b0fd61b27e9ac4cc312a9dadbf1f7e8