Merging and deploying - alphagov/notifications-manuals GitHub Wiki
Overview
You should only merge a PR if you're going to deploy it straight away. Whatever is on master should also be in production, unless there's a problem with the deployment. A typical sequence looks like the following:
- Check if there are any outstanding deployments for the app.
- Post about it in
#govuk-notify
e.g. ":mouse: admin". - Merge the branch and monitor the apps pipeline in Concourse.
- You need to be on the VPN to access Concourse.
- Wait for the new version to deploy to the Preview environment.
- Do any additional manual testing you need to do in Preview.
- You need to be on the VPN to access this environment.
- Deploy to Staging and then Production (see below for this).
- We don't normally do any further testing in Staging.
If your deployment fails for some reason, you should start a thread in Slack to keep everyone informed. You should also keep an eye on the #govuk-notify-release
channel, as some failure notifications will appear there.
Merging
Reviewing a third-party PR
If a third-party user creates a PR against any of our repos, Concourse won't automatically run any tests against it. This is because it would be simple for that user to edit the PR to perform malicious actions in the test script. For these pull requests, the process should be two-stage.
-
Manually look through the PR. At this stage we're just interested in does the PR seem honest and well intentioned, or does it look like it'll do something malicious. You don't need to create and publish a GitHub review at this point.
-
Pull the branch and then push it.
export PULL_REQUEST_ID=123 # grab this ID from the URL of their pull request git fetch origin pull/$PULL_REQUEST_ID/head:concourse-test-pr-$PULL_REQUEST_ID git checkout concourse-test-pr-$PULL_REQUEST_ID git push
-
Follow the link from the output to open the new PR.
Because the new PR is created from within the repo rather than from a fork, concourse will run. Then, because the head commit has the same code sha as the third party's branch, Concourse will update their PR with a ✅ or a ❌ too! Note that the third party isn't able to see the actual test run details, so you'll need to tell them what went wrong.
If you rebase, merge, or add commits to your branch (or if they add commits to their branch) this won't work.
Deployment
Some apps are continuously deployed. This means it will be automatically deployed to preview, then staging and then production, as long as the functional tests pass at each stage.
- Apps which are continuously deployed will tell you they are in their pull request template.
- In Concourse, you can see if there's a solid (CD) or dashed (manual) line between the stages.
Apps which are not continuously deployed when you merge a pull request will be deployed to preview automatically but you will need to deploy it yourself to staging and then to production.
- Wait for the functional tests to pass in the preceding stage.
- Click on the stage to deploy to staging / production.
- Click the "+" button (top right) to kick off the deployment.
Note that preview and staging both require you to be on the VPN.
Deploying a branch before merging
This is a quick way to get extra confidence about a change before merging it. See Deploying a demo app image to preview before merging
Override Continuous Deployment
To stop a continuously deploying app from deploying automatically, you should pause the concourse job that deploys to staging. To do this
-
Go to the staging deploy job, for example https://concourse.notify.tools/teams/notify/pipelines/document-download-frontend/jobs/deploy-document-download-frontend-staging/builds/47
-
Click on the name of the deployment job in the green bar
-
Click on the pause symbol to the left of the job name. Your job is now paused and is shown as blue in the pipeline view
-
You can now merge your pull request, wait for it to finish deploying to preview and then test your changes on preview.
-
As long as your changes are fine, you can unpause the staging deploy job by repeating steps 1-3 and clicking the play symbol. Your job in the pipeline view should go green again and will automatically deploy.
If you wish to test changes on staging, you should follow the above instructions but pause the production deploy job instead of the staging deploy job.