File tree Expand file tree Collapse file tree 2 files changed +28
-10
lines changed Expand file tree Collapse file tree 2 files changed +28
-10
lines changed Original file line number Diff line number Diff line change 3
3
set -ex
4
4
5
5
image_name=$1
6
+ bucket_name=$2
6
7
echo " Checking if image $image_name exists in OpenStack"
7
8
image_exists=$( openstack image list --name " $image_name " -f value -c Name)
8
9
@@ -11,7 +12,7 @@ if [ "$image_exists" == "$image_name" ]; then
11
12
else
12
13
echo " Image $image_name not found in OpenStack. Getting it from S3."
13
14
14
- wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/openhpc-images /$image_name --progress=dot:giga
15
+ wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/$bucket_name /$image_name --progress=dot:giga
15
16
16
17
echo " Uploading image $image_name to OpenStack..."
17
18
openstack image create --file " $image_name " --disk-format qcow2 " $image_name " --progress
Original file line number Diff line number Diff line change 5
5
inputs :
6
6
image_name :
7
7
type : string
8
- description : Image name from https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/openhpc-images /
8
+ description : Image name from https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/{BUCKET_NAME} /
9
9
required : true
10
-
11
- # push:
12
- # branches:
13
- # - main
14
- # - master
15
- # - feat/fatimage-auto-upload
10
+ bucket_name :
11
+ type : choice
12
+ required : true
13
+ description : Bucket name
14
+ options :
15
+ - openhpc-images
16
+ # - openhpc-images-prerelease
16
17
17
18
jobs :
18
19
image_upload :
19
20
runs-on : ubuntu-22.04
20
21
concurrency : ${{ github.ref }}
21
22
env :
22
23
OS_CLOUD : openstack
23
- IMAGE_LIST : " RL8 RL9"
24
24
steps :
25
25
- uses : actions/checkout@v4
26
26
36
36
. venv/bin/activate
37
37
pip install -U pip
38
38
pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt)
39
- bash .github/bin/get-s3-image.sh ${{ inputs.image_name }}
39
+ bash .github/bin/get-s3-image.sh ${{ inputs.image_name }} ${{ inputs.bucket_name }}
40
+
41
+ - name : Cleanup OpenStack Image (on error or cancellation)
42
+ if : cancelled()
43
+ run : |
44
+ . venv/bin/activate
45
+ image_hanging=$(openstack image list --name ${{ inputs.image_name }} -f value -c ID)
46
+ if [ -n "$image_hanging" ]; then
47
+ echo "Cleaning up OpenStack image with ID: $image_hanging"
48
+ openstack image delete $image_hanging
49
+ else
50
+ echo "No image ID found, skipping cleanup."
51
+ fi
52
+ shell : bash
53
+
54
+ - name : Confirm Success
55
+ if : success()
56
+ run : echo "Deployment succeeded, no cleanup needed."
You can’t perform that action at this time.
0 commit comments