-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (49 loc) · 2.01 KB
/
undeploy-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
name: Undeployment Start
on:
workflow_call:
inputs:
env-name:
type: string
required: true
description: The spack-env-compliant model name to remove
deployment-environment:
type: string
required: true
description: The GitHub deployment environment name
jobs:
undeploy-from-environment:
name: Undeploy ${{ inputs.env-name }} from ${{ inputs.deployment-environment }}
runs-on: ubuntu-latest
environment: ${{ inputs.deployment-environment }}
steps:
- 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: Undeploy
# ssh into deployment environment, create and activate the env, remove all the unneeded environments
id: undeploy
run: |
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
. ${{ vars.SPACK_CONFIG_LOCATION }}/spack-enable.bash
envs=$(find ${{ vars.SPACK_LOCATION }}/var/spack/environments -type d -name '${{ inputs.env-name }}' -printf '%f ')
for env in $envs; do
spack env activate $env
spack uninstall --remove --dependents --yes-to-all --all
spack env deactivate $env
spack env rm $env --yes-to-all
done
spack gc --yes-to-all
EOT
- name: Undeploy Status Notifier
if: always()
run: |
if [[ "${{ steps.undeploy.outcome }}" == "success" ]]; then
echo "::notice::Deployment ${{ inputs.env-name }} was successfully removed from ${{ inputs.deployment-environment }}, found at ${{ vars.SPACK_LOCATION }}"
else
echo "::error::Deployment ${{ inputs.env-name }} couldn't be removed from ${{ inputs.deployment-environment}}, found at ${{ vars.SPACK_LOCATION }}. Please check manually."
fi