Skip to content

Commit 4ff42ce

Browse files
committed
test upload images commit
1 parent fd6abef commit 4ff42ce

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.github/bin/get-s3-image.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
# Variables (adjust these paths as necessary)
6+
IMAGE_OS=RL9
7+
S3_BUCKET="s3://openhpc-images"
8+
APPLIANCES_ENVIRONMENT_ROOT="$APPLIANCES_ENVIRONMENT_ROOT"
9+
MAIN_TF="$APPLIANCES_ENVIRONMENT_ROOT/terraform/main.tf"
10+
11+
echo "Extracting CI image name from $MAIN_TF"
12+
ci_image=$(grep -oP 'openhpc-[0-9a-zA-Z-]+' "$MAIN_TF" | grep $IMAGE_OS)
13+
14+
echo "Checking if image $ci_image exists in OpenStack"
15+
image_exists=$(openstack image list --name "$ci_image" -f value -c Name)
16+
17+
if [ "$image_exists" == "$ci_image" ]; then
18+
echo "Image $ci_image already exists in OpenStack."
19+
else
20+
echo "Image $ci_image not found in OpenStack. Getting it from S3."
21+
22+
wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/openhpc-images/$ci_image
23+
24+
echo "Uploading image $ci_image to OpenStack..."
25+
openstack image create --file "$ci_image.qcow2" --disk-format qcow2 "$ci_image"
26+
27+
echo "Image $ci_image has been uploaded to OpenStack."
28+
fi
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
name: Upload release images to client sites from s3
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
- feat/fatimage-auto-upload
10+
11+
jobs:
12+
image_upload:
13+
runs-on: ubuntu-22.04
14+
concurrency: ${{ github.ref }}
15+
env:
16+
OS_CLOUD: openstack
17+
CI_CLOUD: ${{ vars.CI_CLOUD }}
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Record which cloud CI is running on
23+
run: |
24+
echo CI_CLOUD: ${{ vars.CI_CLOUD }}
25+
26+
- name: Write clouds.yaml
27+
run: |
28+
mkdir -p ~/.config/openstack/
29+
echo "${{ secrets[format('{0}_CLOUDS_YAML', vars.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
30+
shell: bash
31+
32+
- name: Upload latest image if missing
33+
run: |
34+
/usr/bin/python3.10 -m venv venv
35+
. venv/bin/activate
36+
pip install -U pip
37+
pip install -r requirements.txt
38+
ansible --version
39+
. environments/.stackhpc/activate
40+
ansible-galaxy collection install openstack.cloud
41+
. .github/bin/get-s3-image.sh -o

0 commit comments

Comments
 (0)