-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (67 loc) · 2.69 KB
/
deploy-1-setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Deployment Setup
on:
workflow_call:
inputs:
type:
type: string
required: false
default: release
description: The type of deployment - either 'release' or 'prerelease'
version:
type: string
required: true
description: The version of the model being deployed
jobs:
setup-spack-env:
name: Setup Spack Environment
runs-on: ubuntu-latest
outputs:
model: ${{ steps.get-model.outputs.model }}
env-name: ${{ steps.get-env-name.outputs.env-name }}
steps:
- name: Get Model
id: get-model
# for the cases where the repo name is in uppercase but the package name is lowercase (eg. access-nri/MOM5)
run: echo "model=$(echo ${{ github.event.repository.name }} | tr [:upper:] [:lower:])" >> $GITHUB_OUTPUT
- name: Set Spack Env Name String
id: get-env-name
# replace occurences of '.' with '_' in environment name as spack doesn't support '.'. Ex: 'access-om2-v1.0.0' -> 'access-om2-v1_0_0'.
run: echo "env-name=$(echo '${{ steps.get-model.outputs.model }}-${{ inputs.version }}' | tr '.' '_')" >> $GITHUB_OUTPUT
setup-deployment-env:
name: Setup Deployment Environment
runs-on: ubuntu-latest
outputs:
deployment-environments: ${{ steps.get-deployment-environment.outputs.deployment-environments }}
steps:
- name: Checkout Config
uses: actions/checkout@v4
with:
repository: access-nri/build-cd
- name: Get Environments
id: get-deployment-environment
run: |
if [[ "${{ inputs.type }}" == "release" ]]; then
echo "deployment-environments=$(jq --compact-output '.environments' ./config/deployment-environment.json)" >> $GITHUB_OUTPUT
else if [[ "${{ inputs.type }}" == "prerelease" ]]; then
echo "deployment-environments=$(jq --compact-output '.prerelease-environments' ./config/deployment-environment.json)" >> $GITHUB_OUTPUT
else
echo "::error::The 'type' input was invalid. Check the inputs documentation."
exit 1
fi
deployment:
name: Deployment
needs:
- setup-spack-env
- setup-deployment-env
strategy:
fail-fast: false
matrix:
deployment-environment: ${{ fromJson(needs.setup-deployment-env.outputs.deployment-environments) }}
uses: access-nri/build-cd/.github/workflows/deploy-2-start.yml@main
with:
type: ${{ inputs.type }}
model: ${{ needs.setup-spack-env.outputs.model }}
version: ${{ inputs.version }}
env-name: ${{ needs.setup-spack-env.outputs.env-name }}
deployment-environment: ${{ matrix.deployment-environment }}
secrets: inherit