@@ -44,11 +44,42 @@ jobs:
44
44
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
45
45
shell : bash
46
46
47
- - name : Write s3cmd configuration
47
+ - name : Create EC2 credentials if not present
48
+ id : check_creds
48
49
run : |
49
50
. 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
52
83
shell : bash
53
84
54
85
- name : Install s3cmd
0 commit comments