Skip to content

Commit 27958e1

Browse files
committed
allow overriding CI_CLOUD for PRs using label
1 parent cc515da commit 27958e1

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

.github/workflows/fatimage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v2
3131

32+
- name: Record settings for CI cloud
33+
run: |
34+
echo CI_CLOUD: ${{ env.CI_CLOUD }}
35+
3236
- name: Setup ssh
3337
run: |
3438
set -x

.github/workflows/stackhpc.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,33 @@ jobs:
3535
ANSIBLE_FORCE_COLOR: True
3636
OS_CLOUD: openstack
3737
TF_VAR_cluster_name: slurmci-${{ matrix.os_version }}-${{ github.run_number }}
38-
CI_CLOUD: ${{ vars.CI_CLOUD }}
38+
CI_CLOUD: ${{ vars.CI_CLOUD }} # default from repo settings
3939
steps:
4040
- uses: actions/checkout@v2
4141

42+
- name: Override CI_CLOUD if PR label is present
43+
if: ${{ github.event_name == 'pull_request' }}
44+
run: |
45+
# Iterate over the labels
46+
labels=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[].name')
47+
echo $labels
48+
for label in $labels; do
49+
if [[ $label == CI_CLOUD=* ]]; then
50+
# Extract the value after 'CI_CLOUD='
51+
CI_CLOUD_OVERRIDE=${label#CI_CLOUD=}
52+
echo "CI_CLOUD=${CI_CLOUD_OVERRIDE}" >> $GITHUB_ENV
53+
fi
54+
done
55+
4256
- name: Record settings for CI cloud
4357
run: |
44-
echo CI_CLOUD: ${{ vars.CI_CLOUD }}
58+
echo CI_CLOUD: ${{ env.CI_CLOUD }}
4559
4660
- name: Setup ssh
4761
run: |
4862
set -x
4963
mkdir ~/.ssh
50-
echo "${{ secrets[format('{0}_SSH_KEY', vars.CI_CLOUD)] }}" > ~/.ssh/id_rsa
64+
echo "${{ secrets[format('{0}_SSH_KEY', env.CI_CLOUD)] }}" > ~/.ssh/id_rsa
5165
chmod 0600 ~/.ssh/id_rsa
5266
shell: bash
5367

@@ -70,7 +84,7 @@ jobs:
7084
- name: Write clouds.yaml
7185
run: |
7286
mkdir -p ~/.config/openstack/
73-
echo "${{ secrets[format('{0}_CLOUDS_YAML', vars.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
87+
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
7488
shell: bash
7589

7690
- name: Setup environment-specific inventory/terraform inputs
@@ -88,7 +102,7 @@ jobs:
88102
. venv/bin/activate
89103
. environments/.stackhpc/activate
90104
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
91-
terraform apply -auto-approve -var-file="${{ vars.CI_CLOUD }}.tfvars"
105+
terraform apply -auto-approve -var-file="${{ env.CI_CLOUD }}.tfvars"
92106
env:
93107
TF_VAR_os_version: ${{ matrix.os_version }}
94108

@@ -97,7 +111,7 @@ jobs:
97111
. venv/bin/activate
98112
. environments/.stackhpc/activate
99113
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
100-
terraform destroy -auto-approve -var-file="${{ vars.CI_CLOUD }}.tfvars"
114+
terraform destroy -auto-approve -var-file="${{ env.CI_CLOUD }}.tfvars"
101115
if: failure() && steps.provision_servers.outcome == 'failure'
102116
env:
103117
TF_VAR_os_version: ${{ matrix.os_version }}
@@ -197,7 +211,7 @@ jobs:
197211
. venv/bin/activate
198212
. environments/.stackhpc/activate
199213
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
200-
terraform destroy -auto-approve -var-file="${{ vars.CI_CLOUD }}.tfvars"
214+
terraform destroy -auto-approve -var-file="${{ env.CI_CLOUD }}.tfvars"
201215
if: ${{ success() || cancelled() }}
202216
env:
203217
TF_VAR_os_version: ${{ matrix.os_version }}

0 commit comments

Comments
 (0)