-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (91 loc) · 4.27 KB
/
deploy-2-start.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Deploy Start
concurrency: ${{ inputs.deployment-environment }}
on:
workflow_call:
inputs:
type:
type: string
required: true
description: The type of deployment - either 'release' or 'prerelease'
model:
type: string
required: true
description: The model to deploy
version:
type: string
required: true
description: The version of the model to deploy
env-name:
type: string
required: true
description: The spack-env-compliant environment name for the model
deployment-environment:
type: string
required: true
description: The GitHub deployment environment name
jobs:
deploy-to-environment:
name: Deploy to ${{ inputs.deployment-environment }}
runs-on: ubuntu-latest
environment: ${{ inputs.deployment-environment }}
steps:
# Deployment
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Get packages and config versions
id: versions
run: |
echo "packages=$(jq --compact-output --raw-output '."spack-packages"' ./config/versions.json)" >> $GITHUB_OUTPUT
echo "config=$(jq --compact-output --raw-output '."spack-config"' ./config/versions.json)" >> $GITHUB_OUTPUT
- name: Setup SSH
id: ssh
uses: access-nri/actions/.github/actions/setup-ssh@main
with:
private-key: ${{ secrets.SSH_KEY }}
hosts: |
${{ secrets.HOST }}
${{ secrets.HOST_DATA }}
- name: Copy spack.yaml
run: |
rsync -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \
spack.yaml \
${{ secrets.USER }}@${{ secrets.HOST_DATA }}:${{ vars.SPACK_YAML_LOCATION }}
- name: Deploy to ${{ inputs.deployment-environment }}
# ssh into deployment environment, create and activate the env, install the spack.yaml.
run: |
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
git -C ${{ vars.SPACK_PACKAGES_LOCATION }} fetch
git -C ${{ vars.SPACK_PACKAGES_LOCATION }} checkout --force ${{ steps.versions.outputs.packages }}
git -C ${{ vars.SPACK_CONFIG_LOCATION }} fetch
git -C ${{ vars.SPACK_CONFIG_LOCATION }} checkout --force ${{ steps.versions.outputs.config }}
. ${{ vars.SPACK_CONFIG_LOCATION }}/spack-enable.bash
spack env create ${{ inputs.env-name }} ${{ vars.SPACK_YAML_LOCATION }}/spack.yaml
spack env activate ${{ inputs.env-name }}
spack --debug install --fresh || exit $?
spack module tcl refresh --delete-tree -y
spack find --paths > ${{ vars.SPACK_LOCATION }}/var/spack/environments/${{ inputs.env-name }}/spack.location
spack env deactivate
echo "$(date): Deployed ${{ inputs.model }} ${{ inputs.version }} with spack-packages ${{ steps.versions.outputs.packages }}, spack-config ${{ steps.versions.outputs.config }}" >> ${{ vars.SPACK_RELEASE_LOCATION }}/release.log
EOT
# Release
- name: Get Release Metadata
if: inputs.type == 'release'
run: |
rsync -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \
'${{ secrets.USER}}@${{ secrets.HOST_DATA }}:${{ vars.SPACK_LOCATION }}/var/spack/environments/${{ inputs.env-name }}/spack.*' \
./${{ inputs.env-name }}
- name: Create Release
if: inputs.type == 'release'
uses: softprops/[email protected]
with:
tag_name: ${{ inputs.version }}
name: ${{ inputs.model}} ${{ inputs.version }}
body: |
This release of ${{ inputs.model }} ${{ inputs.version }} uses [spack-packages ${{ steps.versions.outputs.packages }}](https://github.com/ACCESS-NRI/spack-packages/releases/tag/${{ steps.versions.outputs.packages }}) and [spack-config ${{ steps.versions.outputs.config }}](https://github.com/ACCESS-NRI/spack-config/releases/tag/${{ steps.versions.outputs.config }}).
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./${{ inputs.env-name }}/spack.yaml
./${{ inputs.env-name }}/spack.lock
./${{ inputs.env-name }}/spack.location