|
1 | 1 | # build-cd
|
2 | 2 |
|
3 |
| -This repository houses reusable workflows for the building and deployment of ACCESS-NRI models to different environments. |
| 3 | +This repository houses reusable workflows for the building and deployment of ACCESS-NRI models to different environments. |
4 | 4 |
|
5 | 5 | ## Overview
|
6 | 6 |
|
7 |
| -This repository is broken down into two folders: `config` and `.github/workflows`. |
| 7 | +This repository is broken down into two folders: `config` and `.github/workflows`. |
8 | 8 |
|
9 |
| -`config` contains information on the deployment environments that the models deploy to, which is currently just the name of the deployment target. This is used by the aforementioned deployment workflows to gather secrets and configuration details from the associated GitHub Environment. |
| 9 | +`config` contains information on the deployment environments that the models deploy to, which is currently just the name of the deployment target. This is used by the aforementioned deployment workflows to gather secrets and configuration details from the associated GitHub Environment. |
10 | 10 |
|
11 | 11 | `.github/workflows` houses validation and reusable deployment workflows that are called by ACCESS-NRI model repositories. Currently, only [ACCESS-NRI/ACCESS-OM2](https://github.com/ACCESS-NRI/access-om2) is supported.
|
12 | 12 |
|
13 |
| -Below is a brief summary of the two pipelines, `deploy-*` and `validate-json`. |
| 13 | +Below is a brief summary of the three pipelines, `deploy-*`, `undeploy-*` and `validate-json`. |
14 | 14 |
|
15 |
| -### deploy-* |
| 15 | +### `deploy-*` |
16 | 16 |
|
17 |
| -This pipeline is responsible for the gathering of configuration information, building and deployment of whatever model repository calls it. It is split into two workflows, as noted below. |
| 17 | +#### Inputs |
18 | 18 |
|
19 |
| -#### deploy-1-setup.yml |
| 19 | +| Name | Type | Description | Required | Default | Example | |
| 20 | +| ---- | ---- | ----------- | -------- | ------- | ------- | |
| 21 | +| `type` | string | The type of deployment - either 'release' or 'prerelease' | true | `release` | `prerelease` | |
| 22 | +| `version` | string | The version of the model being deployed | true | N/A | `2024.01.1` | |
20 | 23 |
|
21 |
| -This workflow obtains the relevant spack and GitHub Environment information, and creates parallelized deployments based on the list of environments. |
| 24 | +#### Explanation |
22 | 25 |
|
23 |
| -#### deploy-2-start.yml |
| 26 | +This pipeline is responsible for the gathering of configuration information, building and deployment of whatever model repository calls it. It is split into two workflows. |
24 | 27 |
|
25 |
| -Using the GitHub Environment, it `ssh`s into the deployment environments `spack` instance, and installs the model associated with the repository that called it. It then copies back relevant metadata and creates a versioned GitHub Release in the caller repository. |
| 28 | +##### `deploy-1-setup.yml` |
26 | 29 |
|
27 |
| -### validate-json |
| 30 | +This workflow obtains the relevant spack and GitHub Environment information, and creates parallelized deployments based on the list of environments. |
28 | 31 |
|
29 |
| -This workflow is used to validate the `config` folders `*.json` files based on their associated `*.schema.json`. This is used for PR checks on the `build-cd` repo itself. |
| 32 | +##### `deploy-2-start.yml` |
| 33 | + |
| 34 | +Using the GitHub Environment, it `ssh`s into the deployment environments `spack` instance, and installs the model associated with the repository that called it. It then copies back relevant metadata and creates a versioned GitHub Release in the caller repository, if it is not a `prerelease` deployment. |
| 35 | + |
| 36 | +### `undeploy-*` |
| 37 | + |
| 38 | +#### Inputs |
| 39 | + |
| 40 | +| Name | Type | Description | Required | Default | Example | |
| 41 | +| ---- | ---- | ----------- | -------- | ------- | ------- | |
| 42 | +| `version-pattern` | string | A wildcard-supported string for version(s) of the model being removed | true | N/A | `2024.01.1-pre*` | |
| 43 | + |
| 44 | +#### Explanation |
| 45 | + |
| 46 | +This pipeline is responsible for removing deployed models from a deployment environment. Particular use-cases include removing `prerelease` builds from a deployment environment once a PR is merged. |
| 47 | + |
| 48 | +##### `undeploy-1-setup.yml` |
| 49 | + |
| 50 | +This workflow obtains the relevant spack and GitHub Environment information, and creates parallelized jobs removing the given `spack` environments based on the list of deployment environments. |
| 51 | + |
| 52 | +##### `undeploy-2-start.yml` |
| 53 | + |
| 54 | +Using the GitHub Environment, it `ssh`s into the deployment environments `spack` instance, and installs the model associated with the repository that called it. It then copies back relevant metadata and creates a versioned GitHub Release in the caller repository, if it is not a `prerelease` deployment. |
| 55 | + |
| 56 | +### `validate-json.yml` |
| 57 | + |
| 58 | +This workflow is used to validate the `config` folders `*.json` files based on their associated `*.schema.json`. This is used for PR checks on the `build-cd` repo itself. |
| 59 | + |
| 60 | +### `create-deployment-spack.yml` |
| 61 | + |
| 62 | +This workflow is used to create a version of `spack` on `Gadi`. |
| 63 | + |
| 64 | +#### Inputs |
| 65 | + |
| 66 | +| Name | Type | Description | Required | Default | Example | |
| 67 | +| ---- | ---- | ----------- | -------- | ------- | ------- | |
| 68 | +| `spack-version` | string | A version of `spack` | true | N/A | `0.20` | |
| 69 | +| `spack-packages-version` | string | A version of ACCESS-NRI/spack-packages to be bundled with the install of `spack` | true | `main` | `2023.11.12` | |
| 70 | +| `spack-config-version` | string | A version of ACCESS-NRI/spack-config to be bundled with the install of `spack` | true | `main` | `2024.01.01` | |
| 71 | +| `deployment-location` | true | A path in the deployment environment where Spack should be created. For example, if it is `opt/spack`, spack will be installed under `opt/spack/<spack-version>/` | true | N/A | `/opt/spack` | |
30 | 72 |
|
31 | 73 | ## Usage
|
32 | 74 |
|
33 |
| -For supported `spack`-installable ACCESS-NRI models, simply call the `deploy-1-setup.yml` reusable workflow from the given repositories workflow file, like so: |
| 75 | +### Deployment |
| 76 | + |
| 77 | +For supported `spack`-installable ACCESS-NRI models, simply call the `deploy-1-setup.yml` reusable workflow from the given repositories workflow file, as shown below. Don't forget to add required inputs! |
34 | 78 |
|
35 | 79 | ```yml
|
36 | 80 | deploy:
|
37 | 81 | uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@main
|
| 82 | + with: |
| 83 | + type: release |
| 84 | + version: 1.2.3 |
38 | 85 | secrets: inherit
|
39 | 86 | permissions:
|
40 | 87 | contents: write
|
41 | 88 | ```
|
| 89 | +
|
| 90 | +### Removing Deployment |
| 91 | +
|
| 92 | +For given `spack` environments, we can also remove deployments. For example: |
| 93 | + |
| 94 | +```yml |
| 95 | +remove-prereleases: |
| 96 | + uses: access-nri/build-cd/.github/workflows/undeploy-2-setup.yml@main |
| 97 | + with: |
| 98 | + version-pattern: ${{ inputs.model }}-pre* |
| 99 | + secrets: inherit |
| 100 | +``` |
| 101 | + |
| 102 | +This will remove every `spack` environment from the deployment target that matches `<model>-pre*`. |
0 commit comments