Environments and deploy targets
Production, staging and preview environments, who approves a deploy, and where a deploy can go.
An environment is a named place a pipeline deploys to — production, staging, or a preview — with the rules for who may deploy there and the target it ships to. Manage them under the repository's Environments tab.
Kinds and approvals
Each environment is Production, Staging or Preview.
Turn on requires approval and a deploy to that environment waits until someone approves it. List the people allowed to approve; with nobody listed, any maintainer can. Whoever started the run cannot approve their own deploy, unless they own the repository.
A workflow job deploys to an environment with environment::
jobs:
publish:
needs: [build-site]
environment: production
A job like this needs no steps:: the environment's deploy target supplies them.
Deploy targets
The deploy target is where an environment's deploys go. Each one has a driver:
| Driver | Ships to | Strategies |
|---|---|---|
codepinion-container | A hosted app on CodePinion. Set up for you by deploy_app:. | rolling, blue-green, canary |
static-cdn | A static site in your S3-compatible bucket, from artifact:. | rolling |
remote-server | Your own server, by rsync over SSH. | rolling, blue-green |
remote-docker | Docker Compose on your own server. | rolling |
remote-kubernetes | Your own Kubernetes cluster. | rolling |
remote-docker-image | A container image run on your own server. Not available yet. | rolling |
Asking for a strategy the target cannot do fails before anything ships. For a complete workflow file for each target, see Deploy recipes.
remote-docker-image runs an image, and today only a hosted-app deploy builds one, so it cannot be chosen for an environment yet.
Target settings
Open the environment under Environments and choose a driver. The form asks for that driver's settings, and for a Credential: the name of a repository secret, added under Secrets first. The credential is written to a file inside the deploy job only, and is never shown again.
| Driver | Credential secret holds |
|---|---|
static-cdn | The bucket's secret access key. |
remote-server | The SSH private key. |
remote-docker | The SSH private key. |
remote-kubernetes | The whole kubeconfig file. |
Every SSH target needs Known hosts, the server's pinned host key. Get it with ssh-keyscan -p 22 your.server.com and paste the output. Without it CodePinion refuses to connect, because it could not tell your server from an impostor.
static-cdn
| Setting | Required | Default | Meaning |
|---|---|---|---|
| S3 endpoint | Yes | The storage API's base URL, such as https://storage.example.com. | |
| Bucket | Yes | The bucket the site is published into. | |
| Access key ID | Yes | The bucket's access key. Its secret goes in the credential secret. | |
| Region | No | us-east-1 | Used only to sign requests; most S3-compatible servers accept any value. |
| Remove deleted files | No | true | Delete files no longer in the build. Set false only if something else writes to the bucket. |
| Key prefix | No | Publish under this path in the bucket instead of at its root. |
remote-server
| Setting | Required | Default | Meaning |
|---|---|---|---|
| Host | Yes | The server's hostname or public IP. | |
| SSH user | No | deploy | The account CodePinion connects as. |
| Remote path | No | ~/app | Where the code is copied to. |
| Known hosts | Yes | The server's pinned host key. | |
| Post-deploy command | No | Run over SSH after the copy, such as sudo systemctl restart app. With blue-green it runs in the new release, before the switch. | |
| Releases to keep | No | 5 | Blue-green only. How many earlier releases stay on disk, which is how far back a rollback can go. |
remote-docker
| Setting | Required | Default | Meaning |
|---|---|---|---|
| Host | Yes | The server's hostname or public IP. | |
| SSH user | No | deploy | The account CodePinion connects as. |
| Remote path | No | ~/app | Where the code is copied before compose runs. |
| Compose file | No | docker-compose.yml | Relative to the remote path. |
| Known hosts | Yes | The server's pinned host key. |
remote-kubernetes
| Setting | Required | Default | Meaning |
|---|---|---|---|
| Manifest path | No | . | The directory or file to apply: with -k if it holds a kustomization.yaml, otherwise with -R -f. |
| Namespace | No | Passed as --namespace. The namespace must already exist. | |
| Custom command | No | Replaces kubectl apply, such as a helm upgrade --install line. |
Test connection on a saved target checks that CodePinion can reach it, without deploying anything.
Release strategies
Set strategy: on a deploy job:
- rolling replaces instances a few at a time.
- blue-green starts the new version beside the old one, then switches all traffic at once. On a hosted app it first waits for
health_pathto answer; on your own server the post-deploy command is the check. - canary sends a growing share of traffic to the new version in steps, waiting at each one:
strategy:
type: canary
steps: [10, 50, 100]
interval: 300
Steps must climb and end at 100, with at most 10 of them. With no steps: a canary goes 10% then 100%; interval is the seconds each step waits, from 30 to 86,400 (default 300).
During a release
A canary's progress appears on its run, under Actions, as a Canary release panel showing the share of traffic on each version.
At each step CodePinion checks the new version:
- If any of its containers has restarted since the release began, the canary rolls back on its own.
- If not all of its containers are ready yet, it waits another interval instead of failing.
- If it is healthy, it moves to the next step. After the last step, the new version becomes the stable one.
Maintainers can act on a running canary:
| Button | Does |
|---|---|
| Pause | Holds the current split until resumed. |
| Resume | Carries on from the current step. |
| Promote now | Skips the remaining steps and sends all traffic to the new version. Asks first. |
| Roll back | Sends all traffic back to the previous version at once. Does not ask. |
To go back to an earlier release of any environment, use Re-deploy on that deployment under Environments, or Roll back on a hosted app's Deployments tab. A rollback goes through the environment's approval rule like any other deploy.
Static sites
A build job names the directory it produces with artifact:, and a deploy job ships it:
jobs:
build-site:
image: node
steps:
- run: npm ci
- run: npm run build
artifact:
path: dist
publish:
needs: [build-site]
environment: production
The full rules for every key are in the Workflow file reference.