Refer to https://vortex.drevops.com/latest/usage/deploy for more information.
- Code is authored on a local machine by a developer.
- Once the code is ready, it is pushed to GitHub. A pull request needs to be opened for this code change.
- The CI "listens" for code changes and will start an automated build.
- At the end of the build, when all tests have passed, the CI will trigger a deployment to Lagoon.
- Once deployed, a PR environment will appear with a PR name. The database will be taken from production environment. All pending update hooks and other deployment operations will run during deployment.
Once PR is closed, the environment will be automatically removed.
GitHub is a primary code repository for this project (aka "source repository"). Acquia Cloud is a hosting provider for this project and it also has a git repository (aka "destination repository").
The website gets deployed using artifact built on CI and pushed to Acquia Cloud.
There are 2 types of deployments: feature branches and release tags. They are exactly the same except for the resulting branch name on Acquia Cloud (see below).
- Create a Deployer user ([email protected]) account in Acquia.
- Add this user to Acquia Cloud application with a role that allows to push code and use Cloud API.
- Login with Deployer user and go to Acquia Cloud UI->Account->Credentials-> Copy email and key from section "Cloud API".
- SSH into non-production server and run
drush ac-api-login
. Enter copied email and key when prompted. This will store credentials to$HOME/.acquia/cloudapi.conf
and they will not need to be entered again. This allows to use Cloud API drush commands within hooks. - Create SSH key (use
[email protected]
as an email to distinguish SSH keys) and add it to this user. This key cannot be re-used between projects! - Login to CircleCI, go to Settings->SSH Permissions->Add SSH Key and paste * private* key. This allows to push the code from CI to Acquia git repository.
- Copy SHH key fingerprint (looks
like
16:02:e3:ca:33:04:82:58:e8:e9:3e:5d:82:17:86:b1
) and replace it inside.circleci/config.yml
.
- Developer updates DB in the Acquia Cloud environment by copying PROD database to required environment.
- Developer pushes code update to the GitHub branch.
- CI system picks-up the update and does the following:
- Builds a website using production DB.
- Runs code standard checks and Behat tests on the built website.
- Creates a deployment artifact (project files to be pushed to Acquia Cloud repository).
- Pushes created artifact to the Acquia Cloud repository:
- for feature-based branches (i.e.
feature/ABC-123
orbugfix/ABC-123
) the code is pushed to the branch with exactly the same name. - for release deployments, which are tag-based (i.e.0.1.4
), the code is pushed to the branchdeployment/[tag]
(i.e.deployment/0.1.4
). - Acquia Cloud picks up recent push to the repository and runs post code update hooks on the environments where code is already deployed. OR
- If the branch has not been deployed into any Acquia Cloud environment yet and the developer starts the deployment, Acquia Cloud runs post code deploy hooks on the environment where code is being deployed.
- Release branch exists as
deployment/X.Y.Z
in remote GitHub repository. - Release tag exists as
X.Y.Z
in remote GitHub repository. - The
HEAD
of themain
branch hasX.Y.Z
tag assigned. - The hash of the
HEAD
of themain
branch exists in thedevelop
branch. This is to ensure that everything pushed tomain
exists indeveloped
(in case ifmain
had any hot-fixes that not yet have been merged todevelop
). - There are no PRs in GitHub related to releases.
- Release branch is available on Acquia Cloud as
deployment/X.Y.Z
branch. Note: we are building release branches on Acquia Cloud out of tags in GitHub. - Release branch
deployment/X.Y.Z
is deployed into PROD environment. Note: we are NOT deploying tags to Acquia Cloud PROD.
Since Acquia Cloud becomes a destination repository, the following rules MUST be followed by all developers:
- There should be no direct access to Acquia Cloud repository for anyone except for project Technical Lead and Deployer user.
- There should be no pushes to Acquia Cloud repository.
- There may be
main
ordevelop
branch in Acquia Cloud repository. - Technical Lead is expected to regularly cleanup
feature/*
andbugfix/*
branches in Acquia Cloud repository.
To fresh the database in the existing Lagoon environment with the database from production environment, run:
VORTEX_DEPLOY_BRANCH=<YOUR/BRANCH-NAME> VORTEX_DEPLOY_ACTION=deploy_override_db ahoy deploy