@@ -44,11 +44,42 @@ jobs:
4444 echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
4545 shell : bash
4646
47- - name : Write s3cmd configuration
47+ - name : Create EC2 credentials if not present
48+ id : check_creds
4849 run : |
4950 . venv/bin/activate
50- S3_CREDS=$(openstack ec2 credentials create)
51- echo "$S3_CREDS" > ~/.s3cfg
51+ # List existing EC2 credentials
52+ existing_creds=$(openstack ec2 credentials list --format json)
53+
54+ # Check if the list is empty
55+ if [ "$(echo "$existing_creds" | jq 'length')" -eq 0 ]; then
56+ echo "No existing EC2 credentials found."
57+ new_creds=$(openstack ec2 credentials create --format json)
58+ access_key=$(echo "$new_creds" | jq -r '.access')
59+ secret_key=$(echo "$new_creds" | jq -r '.secret')
60+ echo "Created new EC2 credentials."
61+ else
62+ echo "Existing EC2 credentials found."
63+ access_key=$(echo "$existing_creds" | jq -r '.[0].access')
64+ secret_key=$(echo "$existing_creds" | jq -r '.[0].secret')
65+ fi
66+
67+ # Save access and secret keys for the next step
68+ echo "access_key=${access_key}" >> $GITHUB_ENV
69+ echo "secret_key=${secret_key}" >> $GITHUB_ENV
70+ shell : bash
71+
72+ - name : Write s3cmd configuration
73+ run : |
74+ cat <<EOF > ~/.s3cfg
75+ [default]
76+ host_base = https://object.arcus.openstack.hpc.cam.ac.uk
77+ host_bucket = https://object.arcus.openstack.hpc.cam.ac.uk
78+ access_key = ${{ env.access_key }}
79+ secret_key = ${{ env.secret_key }}
80+ use_https = True
81+ signurl_use_https = True
82+ EOF
5283 shell : bash
5384
5485 - name : Install s3cmd
0 commit comments