From ae5838bdff7646507005a9b11b9c1110e6905716 Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Fri, 2 Aug 2024 09:54:39 +1000 Subject: [PATCH] Attempt a decent go of the entire workflow --- .github/workflows/settings-1-update.yml | 2 +- .github/workflows/settings-2-deploy.yml | 66 +++++++++++++------------ config/settings.json | 1 - 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/.github/workflows/settings-1-update.yml b/.github/workflows/settings-1-update.yml index 4fe12e9..61d224d 100644 --- a/.github/workflows/settings-1-update.yml +++ b/.github/workflows/settings-1-update.yml @@ -116,5 +116,5 @@ jobs: with: deployment-environment: ${{ matrix.update.deployment-environment }} spack-type: ${{ matrix.update.type }} - spack-update: '' # {"0.20": "7r8y43r8", "0.21": "wr7834yr", ...} + spack-update: ${{ matrix.update.spack }} # {"0.20": "7r8y43r8", "0.21": "wr7834yr", ...} secrets: inherit diff --git a/.github/workflows/settings-2-deploy.yml b/.github/workflows/settings-2-deploy.yml index 803bdb0..b4be567 100644 --- a/.github/workflows/settings-2-deploy.yml +++ b/.github/workflows/settings-2-deploy.yml @@ -30,36 +30,40 @@ jobs: # hosts: ${{ secrets.HOST }} # private-key: ${{ secrets.SSH_KEY }} - # - name: Update - # run: | - # ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT' - # versions=$(jq --null-input --compact-output --raw-output \ - # --argjson vs "${{ inputs.spack-update }}" \ - # '$vs | keys | @sh' - # ) - # for version in "$versions"; do - # new_commit=$(jq --null-input --compact-output --raw-output \ - # --arg v "$version" \ - # --argjson vs "${{ inputs.spack-update }}" \ - # '$vs[$v]' - # ) - # current_head_commit=$(git -C ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack rev-parse HEAD) - # if [ $? -eq 128 ]; then - # echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack does not exist. Deploy it via build-cds Create Deployment Spack workflow first." - # continue - # fi + - name: Update + env: + GH_TOKEN: ${{ github.token }} + run: | + versions=$(jq --null-input --compact-output --raw-output \ + --argjson vs "${{ inputs.spack-update }}" \ + '$vs | keys | @sh' + ) + for version in $versions; do + new_commit=$(jq --null-input --compact-output --raw-output \ + --arg v "$version" \ + --argjson vs "${{ inputs.spack-update }}" \ + '$vs[$v]' + ) - # git -C ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack fetch + # DEBUG + gh repo clone access-nri/spack ./$version/spack -- -b releases/v$version - # if [[ "$current_head_commit" != "$new_commit" ]]; then - # git -C ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack checkout $new_commit - # if [ $? -ne 0 ]; then - # echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack failed checkout from $current_head_commit to $new_commit" - # else - # echo "::notice::Changed: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack changed from $current_head_commit to $new_commit" - # fi - # else - # echo "::notice::Unchanged: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack left at $current_head_commit" - # fi - # done - # EOT + current_head_commit=$(git -C ./$version/spack rev-parse HEAD) + if [ $? -eq 128 ]; then + echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack does not exist. Deploy it via build-cds Create Deployment Spack workflow first." + continue + fi + + git -C ./$version/spack fetch + + if [[ "$current_head_commit" != "$new_commit" ]]; then + git -C ./$version/spack checkout $new_commit + if [ $? -ne 0 ]; then + echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack failed checkout from $current_head_commit to $new_commit" + else + echo "::notice::Changed: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack changed from $current_head_commit to $new_commit" + fi + else + echo "::notice::Unchanged: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack left at $current_head_commit" + fi + done diff --git a/config/settings.json b/config/settings.json index ddc537f..8330095 100644 --- a/config/settings.json +++ b/config/settings.json @@ -18,4 +18,3 @@ } } } -