Deployment.io

Deploy After Merge


Deploy after merge

A Task can end at a production deployment instead of a pull request. Tick After the PR is merged, deploy to production when you create or start a Task; once you merge its pull request on GitHub, Deployment.io deploys the change to production and checks it there.

The option is off by default. A draft remembers the choice, and Start shows it ticked or not as saved.

When it's available

Deploy after merge works for static sites, web services and private services built from a repository — a service deployed from an image never counts — and for repositories on GitHub only. It's available when every repository in the Task has exactly one production service: a static site, web service or private service, in an environment classified Production, that builds the same repository from the branch the Task starts from.

Otherwise the checkbox is disabled, and the reason for each repository is shown under it:

  • "No production service deploys <repository> from <branch>."
  • "<repository> deploys from <branch> to <environment>, which isn't classified as Production. Classify it as Production to deploy there after merge." An environment's classification is chosen when you create it.
  • "More than one production service deploys <repository> from <branch> (<deployment> (<type>) in <environment>, …). Deploy after merge needs exactly one." The type is "static site", "web service" or "private service".
  • "Deploy after merge follows GitHub pull requests only; <repository> is on <provider>."

"Exactly one" counts across types: a repository that deploys both a static site and a web service from the same branch — a monorepo, for example — has more than one, and its Task ends at its pull request. A Task that includes a repository with no production deployment of its own, such as a shared library, can't use the option either.

The production deployment is found when the Task starts and doesn't change afterwards.

What happens after you merge

Merging the pull request is the approval. Review and merge it on GitHub as you normally would — Deployment.io never merges it. Deployment.io notices the merge within about a minute, through GitHub's pull request webhook. A check every 10 minutes catches any merge the webhook missed.

Each repository deploys when its own pull request merges. For each one:

  1. If the production environment is missing a variable the change needs — the Task's Before deploying list — it waits. Add the variable to the environment and the deploy continues within about a minute.
  2. If the deployment has automatic deployment on git push turned on, Deployment.io doesn't start a second deploy: it follows the first build that deployment starts after the merge. If none has started 30 minutes after the merge, Deployment.io deploys it itself.
  3. Otherwise Deployment.io deploys the deployment's branch as it is at that moment, and records the commit that went out. It doesn't pin a commit, so nothing merged in between is rolled back.

A web service's deploy runs its pre-deploy command before the new version receives traffic, as every deploy of it does.

A deploy that fails is not retried. A pull request closed without merging deploys nothing.

In a Task that changes both a site and the service it calls, merge the service's pull request first. Otherwise the site can go live before the service it depends on. While a service's pull request is open and no site's has merged yet, the Task page shows a hint under "Ends at": "Merge <service repository>'s pull request first: each repository deploys when its own pull request merges, so <site repository> could go live before the service it calls." Nothing enforces the order.

QA on production

Once every repository's deploy has finished and at least one went out, Deployment.io runs QA once more, against production: it checks the Task's acceptance criteria there and reports. Acceptance criteria come from the Task's Acceptance criteria box (see Creating and Running a Task), or from the spec of a Task converted from an Assistant session; a Task without them gets a smoke check instead — each production site loads with no page errors and no failed requests to the site itself. It is report-only — it never changes code or rolls anything back.

What is checked depends on the type of each production deployment.

Static site. The browser checks the acceptance criteria, or the smoke check, on the deployment's custom domain — the one that doesn't redirect to another — or on the deployment's own URL when it has no custom domain. The deployment's other domains are allowed too, so redirects between them still load.

Web service. First, Deployment.io itself sends a GET request to the service's Health check path — the one the load balancer polls, or "/" when none is set (see Deploying a Web Service). A status from 200 to 400 is healthy, the same rule the load balancer uses. Redirects aren't followed, and it tries up to 3 times, 10 seconds apart. Each health check is one result, "<repository>: GET <path> answers with a status from 200 to 400", passed, or failed with the status it answered ("answered 503") or "no answer".

  • With a custom domain (the one that doesn't redirect to another), the health check runs on https://<domain><path>, and the browser checks the acceptance criteria, or the smoke check, on https://<domain>. The service's other custom domains are allowed too. A criterion about how the API answers a plain GET — its status code, a JSON body, or text in the response — is checked by opening https://<domain><path> in the browser. JSON is compared by meaning (the same keys and values), not by spacing or key order, and redirects are followed. Other API criteria come back not checked: one that needs another method (POST, PUT, PATCH or DELETE), request headers or a body, "needs an API request other than a plain GET"; one that needs an API key, a token or a signed-in session, "needs a login"; one about a response header, a redirect's own status, or more of a long response than the browser shows, "needs part of the response the browser doesn't show".
  • Without a custom domain, only the health check runs, over http on the service's own load-balancer address. The browser needs an https address, so the acceptance criteria are reported as not checked, each with "Not checked: no https address to open it in a browser — add a custom domain to <repository>'s service." See Adding Custom Domains.

Private service. Nothing is checked — it has no address — and it doesn't appear in the results. When no repository in the Task has anything to check, for example a Task whose only repository is a private service, QA on production couldn't run: "No production URL to check: <deployment> is a private service with no URL." Several reasons are joined with "; ". The board shows "Deployed · QA couldn't run".

Each health check counts as one check, alongside the acceptance criteria. The Task page shows, for example, "QA on production: 2 of 2 checks passed", and the board "Deployed · QA 2 of 2 passed", in red when one failed. "Deployed · site loads" means only static sites were checked, with no acceptance criteria.

While QA on production runs, the Task page shows "Checking production…". Under the results, "Checked:" lists each address QA checked, with its repository. A web service without a custom domain is listed by its health check address, as "<address> (<repository>, health check only)"; that address is plain text, not a link.

The browser it uses is read-only. It blocks every request that could change data — anything other than GET, HEAD or OPTIONS — so a form submitted during the check never reaches your server, and a criterion that can only be checked by changing data is reported as not checked. An API criterion that needs a request other than a plain GET is reported "needs an API request other than a plain GET", even when that request would change data. When only a health check ran, the Task page's note says so: "QA on production is report-only: the change is already live. Here it runs only a health check, which sends GET requests to the service's health check path."

The health check sends only GET requests, to the health check path — up to 3 of them. A GET handler there that changes data would still run, so keep that path free of side effects.

When production QA fails, its section says what you can do next: "You can roll back production below.", "You can roll back production or revert the change below." or "You can revert the change below.", depending on which actions are available.

Production watch

After the deploy, Deployment.io watches production for 30 minutes and compares it with the 30 minutes before the deploy. It is report-only — it never changes or rolls back production. A person always decides, with the actions in Roll back or revert.

It starts at the same time as QA on production, not after it: once every repository's deploy has finished and at least one went out. There is one watch per Task, run by the runner of the deployed environment.

  • It covers the 30 minutes after the last deploy finished.
  • It compares them with a stretch of the same length that ends when the deploy started, so the rollout itself is left out.
  • It reads the numbers about once a minute. Each read counts everything since the deploy.
  • QA on production's own requests count as traffic too.

What it reads depends on the type of each production deployment.

Web service.

  • The load balancer's requests, 5xx responses (the service's own and the load balancer's) and p95 response time.
  • Unhealthy targets in the service's target group.
  • Crashed tasks of the new version.
  • A GET of each address QA on production checks — the health check path, and the custom domain when there is one.

Private service. Crashed tasks of the new version.

Static site. CloudFront's requests and 5xx responses, and a GET of the site's address that QA on production checks. CloudFront publishes a 5xx error rate rather than a count, so the 5xx count is worked out minute by minute from the requests and that rate.

It reads only AWS metrics and ECS task states, plus those GET requests. It doesn't read your application's logs.

Each problem is reported when it's first seen, without waiting for the 30 minutes to end:

  • Unhealthy targets in two reads in a row, shown as "<n> unhealthy targets".
  • A task of the new version that stopped because an essential container exited, it failed to start, or a container ran out of memory, shown as "<n> tasks of this version stopped (<reason>)". Tasks stopped by scaling in or by the deploy itself don't count.
  • A GET that fails in two reads in a row: a status outside 200 to 400 (the same rule as QA on production's health check), or no answer. It's shown as "GET <path> answered <status>" or "GET <path> got no answer (<why>)" — with the path only, never the host or query.
  • Errors up, when all three hold: at least 5 5xx responses since the deploy; at least 1% of requests since the deploy; and at least 3 times the share of requests before the deploy. It's shown as "<n> 5xx of <m> requests since the deploy (<p>%), <a> of <b> before".

Response time is shown but never judged.

The result is the summary line at the top of the "Production watch" section on the Task page's Details tab:

  • "Starting the production watch…", then "Watching production until <time>" while it runs ("Watching production…" until the end time is known).
  • "Problems after the deploy" — a problem above was seen. The section lists them under "What got worse:", one per line as "<repository>: <what>". It also says what you can do next, with the same hints as QA on production: "You can roll back production below.", "You can roll back production or revert the change below." or "You can revert the change below.", depending on which actions are available.
  • "Not enough traffic to tell" — no problem was seen, and every web service and static site in the Task had fewer than 50 requests since the deploy. A Task with only private services can't get this result.
  • "No change in the 30 minutes after the deploy" — no problem was seen, and there was enough traffic.
  • "Ended early: <deployment> was rolled back." or "Ended early: <deployment> was deployed again." — the deployment changed during the 30 minutes, so later numbers aren't this Task's. That includes a rollback from the Task page. A newer build that failed or was stopped doesn't count.

When the watch couldn't finish, the summary line is one of:

  • "The production watch couldn't start."
  • "The production watch ended as error." (or "as stopped.", "as timed out.")
  • "The production watch ended without a final report."
  • "The production watch didn't finish within 45 minutes."
  • "Nothing to watch: <reasons>." Each reason is "the deployment <deployment> no longer exists" or "<deployment>'s environment has no runner"; several are joined with "; ".

Under the summary line there is one line per repository with its numbers — for example "api: 1200 requests (1100 before) · 3 5xx (2 before) · p95 180 ms (170 ms before)". Its parts are separated by " · ", each shown only when it applies:

  • the request and 5xx counts, left out when they are all 0 (a private service has none)
  • p95
  • "<n> unhealthy"
  • "<n> crashed"
  • "<n> failing URL" or "<n> failing URLs"

When no part applies, the line says "nothing unusual".

The summary line has a View logs button that opens the watch's job logs. A watch with nothing to watch has no job, so it has no button. Below the lines comes the note "The production watch is report-only: it reads load balancer, CloudFront and ECS numbers and sends GET requests to the production URLs. It never changes or rolls back production." The Task page updates on its own while the watch runs.

The header's tracker has a Production watch stage after QA on production. It shows "Starting", "Watching", then "No change", "Not enough traffic", "Problems since deploy", "Couldn't finish" or "Ended early". The Activity tab has a Production watch group with when it started, each problem as it was seen, and the result. Clicking the stage opens that group. A Task deployed before the watch shipped has no Production watch stage.

When the watch sees a new problem, Deployment.io sends it at once, without waiting for the 30 minutes to end:

  • Slack: a message to the Slack channel set on the affected service's Notifications tab, the channel that already gets its deployment updates.
  • The notification bell: an alert in the dashboard's notification bell for everyone in the organization, "Problems after deploying <Task title>". It opens the Task page.

The Slack message reads:

Problems after deploying <Task title> to <service names>
• <service name>: <what>
Task: <link to the Task page>
The production watch is report-only. Roll back production or revert the change from the Task page.

There is one "• <service name>: <what>" line per new problem, where <what> is the problem as the Task page shows it.

  • Each kind of problem — unhealthy targets, crashed tasks, a failing URL, errors up — is sent once per repository, the first time it's seen.
  • Problems seen in the same read go in one message per channel, even when several of the Task's services share that channel. The bell gets one alert per read that found new problems.
  • A service with no Slack channel gets the bell alert only.
  • No message marks the end of the watch. A problem first seen in the last read is still sent like any other. Nothing is sent for "No change in the 30 minutes after the deploy", "Not enough traffic to tell", "Ended early" or a watch that couldn't finish.

There's no setting for it. To get it in Slack, pick a channel on the service's Notifications tab. The message carries the Task title, the service names and the problem lines above, with paths only, never a host or query.

Only numbers leave your account. The runner sends Deployment.io the counts, the problem lines above and the addresses that failed — never log lines or response bodies.

The GET requests go to the same addresses QA on production checks, about once a minute for 30 minutes. As with QA on production, keep the health check path free of side effects.

Each watch uses one runner. When a Task's deployments are in environments on different runners, only the repositories on the first deployed repository's runner are watched.

Tasks deployed before the production watch shipped have no "Production watch" section.

Roll back or revert

Nothing is rolled back or reverted automatically: a person always decides. The Task drawer offers two actions, and they do different things.

  • Roll back production is fast and temporary. It puts the previous build back on production straight away, but the change is still on main.
  • Revert the change is durable. It opens a pull request that undoes the change on main, and nothing changes until someone merges it.

If you need the change off production now and gone for good, roll back first, then revert.

Roll back production

For each repository the Task deployed, Roll back production redeploys the build that was live before the Task's deploy. It uses the deployment's own Rollback, so it needs the same permission.

It's offered only while nothing else has shipped on top of the Task's deploy. After that the drawer says "<deployment> has been deployed again since this Task, so rolling back from here would undo those deploys too. Roll back from the deployment's Builds tab if you need to."

It isn't available while a deploy is in progress — "A deploy is in progress on <deployment>. Try again when it finishes." — or when there's nothing to go back to: "No earlier successful deploy to roll back to."

The rollback is shown only to people who can read the deployment, and the button only to those with its Rollback permission.

A rollback doesn't run the deployment's pre-deploy command, so database migrations the change applied are not undone — the earlier build runs against the database as the change left it.

For a web service or private service, the dialog says so too: "If this deploy changed the database schema, rolling back the code doesn't undo it — revert the change with a new migration instead."

Main still has the change, and the dialog says so: the next deploy brings it back — with automatic deployment on git push turned on, that's the next merge. To remove the change for good, revert it.

Once the rollback finishes, the drawer shows "Rolled back on <date> to <short commit>".

Revert the change

For each GitHub repository whose pull request merged, Revert the change asks GitHub to open a pull request that reverts it. The drawer then shows "Revert pull request #<n>", linking to it. This works for any Task, whether or not it deployed after merge.

Nothing changes until someone merges the revert pull request. With automatic deployment on git push turned on, merging it also deploys it.

If GitHub can't revert the change — for example because it conflicts with later changes — the drawer shows GitHub's message. In the rare case that GitHub opened the pull request but Deployment.io couldn't save it on the Task, the drawer shows the link and says "Check GitHub before reverting again."

Fix a production problem

When QA on production failed a criterion, or the production watch ended with "Problems after the deploy", the Task page's Details tab shows a Production problems section with Create a fix Task. It appears once QA on production and the watch have both ended. While the watch runs, roll back if production needs it now.

The fix Task

The fix Task is a draft Task, so nothing runs and nothing is spent until you start it. It's titled "Fix problems after deploying <title>" and has:

  • every repository the Task deployed, on its base branch, which already contains the change;
  • the same models and review settings, ending at a deployment;
  • a description of what was deployed (each pull request, commit and deploy time), the problems as recorded data, and what to do: find the cause in that change and fix it, or say so when the cause isn't in the change;
  • QA on production's failed criteria as its acceptance criteria.

Edit it before you start it if you know more. A Task has one fix Task at a time: Create a fix Task opens the existing one. Deleting the fix Task lets you create a new one.

The production logs

When the fix Task runs, its runner reads the logs of each web service and private service from the deploy being fixed, between the deploy and the end of the watch. It gives the agent two files per service: the most recent error lines and the last lines of the window.

The runner reads them in your AWS account and scrubs anything that looks like a token, password or key. IP addresses and email addresses stay as logged, because a problem can depend on one, so the agent, and so your organization's model provider, sees them, as it sees your code. The log files themselves are never sent to Deployment.io.

The agent is told not to quote log lines in its messages or summary. In the run log and summary that Deployment.io keeps, each public IP address is replaced with a placeholder such as [ip-1], and the part of an email address before the @ with one such as [email-1]. Private IP addresses are kept. Names and other personal data in a log line aren't caught.

Static sites have no runtime logs. A service in an environment on a different runner than the fix Task's isn't read.

Dismiss the problems

When the problems need no fix, Dismiss problems moves the Task to Done and out of "Needs you". You can still create a fix Task afterwards. Dismissing can't be undone.

Whether the fix worked

After the fix Task deploys, its own QA on production and production watch check production again. The original Task's Production problems section then says one of:

  • "Fixed in production: the fix's checks after its deploy saw none of these problems."
  • "Still seen after the fix's deploy:", with each problem still seen.
  • "The fix deployed, but its production checks couldn't confirm these problems are gone."
  • "The fix Task ended without deploying. Delete it to create a new fix Task, or dismiss the problems."

A problem the fix's watch finds that the original didn't have shows on the fix Task itself.

The fix Task's Details tab shows "Fixes <title>", linking back. The original shows "Fix Task: <title>" with the fix Task's status. In "Needs you", the original's row offers Open fix Task.

What you'll see

The Task page shows "Ends at: Production" (or "Ends at: Pull request"). Under "Ends at: Production", a Task that changes both a site and a service can show the merge-order hint while the service's pull request is open and no site's has merged yet.

Under each repository, below its pull request, it shows "Deploys to <deployment> (<type>) in <environment>" — for example "Deploys to api (web service) in Production" — then one of:

  • "after merge"
  • "Waiting for merge"
  • "Waiting for variables: <names>"
  • "Waiting for AutoDeploy's build"
  • "Deploying"
  • "Deployed · <short commit>"
  • "Deploy failed"
  • "Not deployed", with the reason

A View build link appears once there is a build; it opens the service's Builds tab.

On the board, these Tasks have their own status tags:

  • Needs action — "Merge to deploy", "Add 2 variables" (the count varies), "Deploy failed" or "Problems since deploy".
  • Running — "Deploying", "Checking production", "Deployed · watching" or "Fix started".
  • Done — "Deployed · site loads", "Deployed · QA 3 of 3 passed" (the counts vary), "Deployed · QA couldn't run" or "Fixed in production".

"Checking production" shows while QA on production runs, and "Deployed · watching" after it finishes while the production watch is still running. When the watch finishes with "Problems after the deploy", the card shows "Problems since deploy"; otherwise — "No change", "Not enough traffic to tell", "Ended early", a watch that couldn't finish, or a Task with no watch — it keeps its QA on production tag in Done.

"Fix started" shows while the Task's fix Task runs, deploys and is checked, and "Fixed in production" once its checks saw none of the problems. Otherwise the card keeps "Problems since deploy" or its QA on production tag.

A must-fix finding still shows "PR held · must-fix open" first.