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.

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."

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) or "Deploy failed".
  • Running — "Deploying" or "Checking production".
  • Done — "Deployed · site loads", "Deployed · QA 3 of 3 passed" (the counts vary) or "Deployed · QA couldn't run".

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