Skip to content

Commit fd278a6

Browse files
committed
settings-*.yml: Updated to deploy updates to spack-config
1 parent a41494b commit fd278a6

File tree

2 files changed

+48
-18
lines changed

2 files changed

+48
-18
lines changed

.github/workflows/settings-1-update.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
update=$(jq --raw-output --compact-output \
7070
'[.deployment | to_entries[] | .key as $d | .value | keys[] | {
7171
"deployment-environment": $d,
72-
"type": .key
72+
"type": .
7373
}]' ${{ env.CONFIG_SETTINGS_PATH }}
7474
)
7575
echo "updates=$update" >> $GITHUB_OUTPUT

.github/workflows/settings-2-deploy.yml

+47-17
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,30 @@ jobs:
2222

2323
- name: Setup spack updates
2424
id: spack
25-
# TODO: Since we can't format this json as an input for this job (see the earlier workflow) we need to do it here
25+
# TODO: Since we can't format any of this later json as an input for this job (see the earlier workflow) we need to do it here
2626
run: |
2727
updates=$(jq --compact-output --raw-output \
2828
--arg env "${{ inputs.deployment-environment }}" \
2929
--arg type "${{ inputs.spack-type }}" \
30-
'.deployment[$env][$type].spack' \
30+
'.deployment[$env][$type] | to_entries[] | "\(.key) \(.value.spack)"' \
3131
${{ env.CONFIG_SETTINGS_PATH }}
3232
)
33-
versions=$(jq --compact-output --raw-output \
33+
34+
echo "$updates"
35+
echo "updates=$updates" >> $GITHUB_OUTPUT
36+
37+
- name: Setup spack-config updates
38+
id: spack-config
39+
run: |
40+
updates=$(jq --compact-output --raw-output \
3441
--arg env "${{ inputs.deployment-environment }}" \
3542
--arg type "${{ inputs.spack-type }}" \
36-
'.deployment[$env][$type].spack | keys | @sh' \
43+
'.deployment[$env][$type] | to_entries[] | "\(.key) \(.value.spack-config"' \
3744
${{ env.CONFIG_SETTINGS_PATH }}
3845
)
3946
4047
echo "$updates"
41-
echo "$versions"
42-
4348
echo "updates=$updates" >> $GITHUB_OUTPUT
44-
echo "versions=$versions" >> $GITHUB_OUTPUT
4549
4650
- name: Setup SSH
4751
id: ssh
@@ -50,20 +54,16 @@ jobs:
5054
hosts: ${{ secrets.HOST }}
5155
private-key: ${{ secrets.SSH_KEY }}
5256

53-
- name: Update
57+
- name: Update Spack
5458
continue-on-error: true
5559
run: |
5660
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
5761
set +e
58-
for version in ${{ steps.spack.outputs.versions }}; do
59-
new_commit=$(jq --compact-output --raw-output \
60-
--arg v "$version" \
61-
--arg env "${{ inputs.deployment-environment }}" \
62-
--arg type "${{ inputs.spack-type }}" \
63-
'.deployment[$env][$type].spack[$v]' \
64-
${{ env.CONFIG_SETTINGS_PATH }}
65-
)
62+
while read -ra update; do
63+
version=${update[0]}
64+
new_commit=${update[1]}
6665
current_head_commit=$(git -C ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack rev-parse HEAD)
66+
6767
if [ $? -eq 128 ]; then
6868
# FIXME: Deploy spack instances in this job too.
6969
echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack does not exist. Deploy it via build-cds Create Deployment Spack workflow first."
@@ -82,5 +82,35 @@ jobs:
8282
else
8383
echo "::notice::Unchanged: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack left at $current_head_commit"
8484
fi
85-
done
85+
done <<< "${{ steps.spack.outputs.updates }}"
86+
EOT
87+
88+
- name: Update spack-config
89+
continue-on-error: true
90+
run: |
91+
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
92+
set +e
93+
while read -ra update; do
94+
version=${update[0]}
95+
new_commit=${update[1]}
96+
current_head_commit=$(git -C ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack-config rev-parse HEAD)
97+
98+
if [ $? -eq 128 ]; then
99+
echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack-config does not exist."
100+
continue
101+
fi
102+
103+
git -C ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack-config fetch
104+
105+
if [[ "$current_head_commit" != "$new_commit" ]]; then
106+
git -C ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack-config checkout $new_commit
107+
if [ $? -ne 0 ]; then
108+
echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack-config failed checkout from $current_head_commit to $new_commit"
109+
else
110+
echo "::notice::Changed: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack-config changed from $current_head_commit to $new_commit"
111+
fi
112+
else
113+
echo "::notice::Unchanged: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack-config left at $current_head_commit"
114+
fi
115+
done <<< "${{ steps.spack-config.outputs.updates }}"
86116
EOT

0 commit comments

Comments
 (0)