55 push :
66 branches :
77 - main
8+ paths :
9+ - ' **'
10+ - ' !dev/**'
11+ - ' dev/setup-env.sh'
12+ - ' !docs/**'
13+ - ' !README.md'
14+ - ' !.gitignore'
815 pull_request :
16+ paths :
17+ - ' **'
18+ - ' !dev/**'
19+ - ' dev/setup-env.sh'
20+ - ' !docs/**'
21+ - ' !README.md'
22+ - ' !.gitignore'
923jobs :
1024 openstack :
1125 name : openstack-ci
@@ -23,43 +37,57 @@ jobs:
2337 ANSIBLE_FORCE_COLOR : True
2438 OS_CLOUD : openstack
2539 TF_VAR_cluster_name : slurmci-${{ matrix.os_version }}-${{ github.run_number }}
26- CI_CLOUD : ${{ vars.CI_CLOUD }}
40+ CI_CLOUD : ${{ vars.CI_CLOUD }} # default from repo settings
2741 TF_VAR_os_version : ${{ matrix.os_version }}
2842 steps :
2943 - uses : actions/checkout@v2
3044
45+ - name : Override CI_CLOUD if PR label is present
46+ if : ${{ github.event_name == 'pull_request' }}
47+ run : |
48+ # Iterate over the labels
49+ labels=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[].name')
50+ echo $labels
51+ for label in $labels; do
52+ if [[ $label == CI_CLOUD=* ]]; then
53+ # Extract the value after 'CI_CLOUD='
54+ CI_CLOUD_OVERRIDE=${label#CI_CLOUD=}
55+ echo "CI_CLOUD=${CI_CLOUD_OVERRIDE}" >> $GITHUB_ENV
56+ fi
57+ done
58+
3159 - name : Record settings for CI cloud
3260 run : |
33- echo CI_CLOUD: ${{ vars .CI_CLOUD }}
61+ echo CI_CLOUD: ${{ env .CI_CLOUD }}
3462
3563 - name : Setup ssh
3664 run : |
3765 set -x
3866 mkdir ~/.ssh
39- echo "${{ secrets[format('{0}_SSH_KEY', vars .CI_CLOUD)] }}" > ~/.ssh/id_rsa
67+ echo "${{ secrets[format('{0}_SSH_KEY', env .CI_CLOUD)] }}" > ~/.ssh/id_rsa
4068 chmod 0600 ~/.ssh/id_rsa
4169 shell : bash
42-
70+
4371 - name : Add bastion's ssh key to known_hosts
4472 run : cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
4573 shell : bash
46-
74+
4775 - name : Install ansible etc
4876 run : dev/setup-env.sh
4977
5078 - name : Install OpenTofu
5179 uses : opentofu/setup-opentofu@v1
5280 with :
5381 tofu_version : 1.6.2
54-
82+
5583 - name : Initialise terraform
5684 run : terraform init
5785 working-directory : ${{ github.workspace }}/environments/.stackhpc/terraform
58-
86+
5987 - name : Write clouds.yaml
6088 run : |
6189 mkdir -p ~/.config/openstack/
62- echo "${{ secrets[format('{0}_CLOUDS_YAML', vars .CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
90+ echo "${{ secrets[format('{0}_CLOUDS_YAML', env .CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
6391 shell : bash
6492
6593 - name : Setup environment-specific inventory/terraform inputs
@@ -77,14 +105,14 @@ jobs:
77105 . venv/bin/activate
78106 . environments/.stackhpc/activate
79107 cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
80- terraform apply -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
108+ terraform apply -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
81109
82110 - name : Delete infrastructure if provisioning failed
83111 run : |
84112 . venv/bin/activate
85113 . environments/.stackhpc/activate
86114 cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
87- terraform destroy -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
115+ terraform destroy -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
88116 if : failure() && steps.provision_servers.outcome == 'failure'
89117
90118 - name : Configure cluster
@@ -111,14 +139,14 @@ jobs:
111139 run : |
112140 . venv/bin/activate
113141 . environments/.stackhpc/activate
114-
142+
115143 # load ansible variables into shell:
116144 ansible-playbook ansible/ci/output_vars.yml \
117145 -e output_vars_hosts=openondemand \
118146 -e output_vars_path=$APPLIANCES_ENVIRONMENT_ROOT/vars.txt \
119147 -e output_vars_items=bastion_ip,bastion_user,openondemand_servername
120148 source $APPLIANCES_ENVIRONMENT_ROOT/vars.txt
121-
149+
122150 # setup ssh proxying:
123151 sudo apt-get --yes install proxychains
124152 echo proxychains installed
@@ -155,7 +183,7 @@ jobs:
155183 # ansible login -v -a "sudo scontrol reboot ASAP nextstate=RESUME reason='rebuild image:${{ steps.packer_build.outputs.NEW_COMPUTE_IMAGE_ID }}' ${TF_VAR_cluster_name}-compute-[0-3]"
156184 # ansible compute -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
157185 # ansible-playbook -v ansible/ci/check_slurm.yml
158-
186+
159187 - name : Test reimage of login and control nodes (via rebuild adhoc)
160188 run : |
161189 . venv/bin/activate
@@ -164,7 +192,7 @@ jobs:
164192 ansible all -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
165193 ansible-playbook -v ansible/site.yml
166194 ansible-playbook -v ansible/ci/check_slurm.yml
167-
195+
168196 - name : Check sacct state survived reimage
169197 run : |
170198 . venv/bin/activate
@@ -182,7 +210,7 @@ jobs:
182210 . venv/bin/activate
183211 . environments/.stackhpc/activate
184212 cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
185- terraform destroy -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
213+ terraform destroy -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
186214 if : ${{ success() || cancelled() }}
187215
188216 # - name: Delete images
0 commit comments