Skip to content

Commit 64d49ea

Browse files
authored
Docs: tag based deployment (#396)
2 parents 39c746c + cf0702f commit 64d49ea

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed

.markdownlint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ default: true
33

44
# 4-space list indentation works best with MkDocs
55
MD007:
6-
indent: 4
6+
indent: 2
77

88
# Remove line length limit - no one wants to hard wrap all their paragraphs
99
MD013: false

docs/deployment/infrastructure.md

+24-15
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ The following things in Azure are managed outside of Terraform:
1616

1717
## Environments
1818

19-
| Environment | Azure Resource Group | Terraform Workspace | Git Branch |
20-
| ----------- | --------------------------------- | ------------------- | ---------- |
21-
| Dev | `$(AGENCY_RESOURCE_GROUP_PREFIX)-eligibility-dev` | `dev` | `dev` |
22-
| Test | `$(AGENCY_RESOURCE_GROUP_PREFIX)-eligibility-test` | `test` | `test` |
23-
| Prod | `$(AGENCY_RESOURCE_GROUP_PREFIX)-eligibility-prod` | `default` | `prod` |
19+
| Environment | Azure Resource Group | Terraform Workspace | Git Reference |
20+
| ----------- | -------------------------------------------------- | ------------------- | --------------------- |
21+
| Dev | `$(AGENCY_RESOURCE_GROUP_PREFIX)-eligibility-dev` | `dev` | `main` |
22+
| Test | `$(AGENCY_RESOURCE_GROUP_PREFIX)-eligibility-test` | `test` | release candidate tag |
23+
| Prod | `$(AGENCY_RESOURCE_GROUP_PREFIX)-eligibility-prod` | `default` | release tag |
24+
25+
(See [Version number format](../releases.md#version-number-format) for naming pattern for release candidate/release tags.)
2426

2527
All resources in these Resource Groups should be reflected in Terraform in this repository. The exceptions are:
2628

@@ -86,7 +88,14 @@ Docker logs can be viewed in the Advanced Tools for the instance. The URL patter
8688

8789
## Making changes
8890

89-
Terraform is [`plan`](https://www.terraform.io/cli/commands/plan)'d when code is pushed to any branch on GitHub, then [`apply`](https://www.terraform.io/cli/commands/apply)'d when merged to `main`. While other automation for this project is done through GitHub Actions, we use an Azure Pipeline (above) for a couple of reasons:
91+
Terraform is [`plan`](https://www.terraform.io/cli/commands/plan)'d when commits that change any file under the `terraform` directory are either:
92+
93+
- merged into the `main` branch
94+
- tagged with a release candidate or release tag
95+
96+
Then, the Azure DevOps pipeline that ran the `plan` will wait for approval to run [`apply`](https://www.terraform.io/cli/commands/apply).
97+
98+
While other automation for this project is done through GitHub Actions, we use an Azure DevOps Pipeline (above) for a couple of reasons:
9099

91100
- Easier authentication with the Azure API using a service connnection
92101
- Log output is hidden, avoiding accidentally leaking secrets
@@ -133,7 +142,7 @@ In general, the steps that must be done manually before the pipeline can be run
133142
- Create Resource Group and storage account dedicated to the Terraform state
134143
- Create container in storage account for Terraform state
135144
- Create environment Resource Group for each environment, Region: West US
136-
- We create these manually to avoid having to give the pipeline service connection permissions for creating resource groups
145+
- We create these manually to avoid having to give the pipeline service connection permissions for creating resource groups
137146
- Create Terraform workspace for each environment
138147
- Trigger a pipeline run to verify `plan` and `apply`
139148
- Known chicken-and-egg problem: Terraform both creates the Key Vault and expects a secret within it, so will always fail on the first deploy. Add the Benefits slack email secret and re-run the pipeline.
@@ -142,14 +151,14 @@ Once the pipeline has run, there are a few more steps to be done manually in the
142151

143152
- [Create the service principal](https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#app-registration-app-objects-and-service-principals)
144153
- Give the ETL service principal access to the `prod` storage account created by the pipeline:
145-
- Navigate to the storage account container
146-
- Select **Access Control (IAM)**
147-
- Select **Add**, then select **Add role assignment**
148-
- In the **Role** tab, select `Storage Blob Data Contributor`
149-
- In the **Members** tab, select `Select Members` and search for the ETL service principal. Add it to the role.
150-
- Also in the **Members** tab, add a description of `This role assignment gives write access only for the path of the hashed data file.`
151-
- In the **Conditions** tab, select **Add condition** and change the editor type to `Code`
152-
- Add the following condition into the editor, filling in `<filename>` with the appropriate value:
154+
- Navigate to the storage account container
155+
- Select **Access Control (IAM)**
156+
- Select **Add**, then select **Add role assignment**
157+
- In the **Role** tab, select `Storage Blob Data Contributor`
158+
- In the **Members** tab, select `Select Members` and search for the ETL service principal. Add it to the role.
159+
- Also in the **Members** tab, add a description of `This role assignment gives write access only for the path of the hashed data file.`
160+
- In the **Conditions** tab, select **Add condition** and change the editor type to `Code`
161+
- Add the following condition into the editor, filling in `<filename>` with the appropriate value:
153162

154163
```text
155164
(

docs/releases.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@ The `eligibility-server` is published as a Docker image on the GitHub Container
44

55
Every push to the `main` (default) branch that changes files relevant to the application builds and updates the `dev` package, via the [`docker-publish`](https://github.com/cal-itp/eligibility-server/blob/main/.github/workflows/docker-publish.yml) GitHub Action.
66

7-
Every release created also pushes a new package publication.
7+
Commits that are tagged with our version number format for release candidates and releases will update the `test` and `prod` packages, respectively.
88

99
## Versions
1010

1111
All versions of the package may be viewed on the [package all versions page](https://github.com/cal-itp/eligibility-server/pkgs/container/eligibility-server/versions).
1212

13-
The `main` (default) branch is published at the `dev` tag:
13+
The `main` (default) branch is published at the `dev` tag.
1414

15-
The official releases will be tagged with a version number and their respective environment (`test`, `prod`) tag.
15+
The official releases will be tagged with a version number.
16+
17+
## Version number format
18+
19+
`eligibility-server` uses the [CalVer](https://calver.org/) versioning scheme, where version numbers for releases look like: `YYYY.0M.R`
20+
21+
- `YYYY` is the 4-digit year of the release; e.g. `2021`, `2022`
22+
- `0M` is the 2-digit, 0-padded month of the release; e.g. `02` is February, `12`
23+
is December.
24+
- `R` is the 1-based release counter for the given year and month;
25+
e.g. `1` for the first release of the month, `2` for the second, and so on.
26+
27+
Version numbers for release candidates append `-rcR`, where `R` is the 1-based release counter for the anticipated release. For example, the first release candidate for the `2024.01.1` release would be `2024.01.1-rc1`.

0 commit comments

Comments
 (0)