@@ -44,11 +44,46 @@ 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+ # Ensure the directory for the .s3cfg file exists
75+ mkdir -p ~/.s3cfg
76+
77+ # Write the s3cmd configuration file
78+ cat <<EOF > ~/.s3cfg
79+ [default]
80+ host_base = https://object.arcus.openstack.hpc.cam.ac.uk
81+ host_bucket = https://object.arcus.openstack.hpc.cam.ac.uk
82+ access_key = ${{ env.access_key }}
83+ secret_key = ${{ env.secret_key }}
84+ use_https = True
85+ signurl_use_https = True
86+ EOF
5287 shell : bash
5388
5489 - name : Install s3cmd
0 commit comments