Skip to content

Commit

Permalink
test upload images commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiethorpe committed Aug 22, 2024
1 parent fd6abef commit 0b9a219
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/bin/get-s3-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -x

# Variables (adjust these paths as necessary)
S3_BUCKET="s3://openhpc-images"
APPLIANCES_ENVIRONMENT_ROOT="$APPLIANCES_ENVIRONMENT_ROOT"
MAIN_TF="$APPLIANCES_ENVIRONMENT_ROOT/terraform/main.tf"

for IMAGE_OS in $IMAGE_LIST; do
echo "Extracting CI image name from $MAIN_TF"
ci_image=$(grep -oP 'openhpc-[0-9a-zA-Z-]+' "$MAIN_TF" | grep $IMAGE_OS)

echo "Checking if image $ci_image exists in OpenStack"
image_exists=$(openstack image list --name "$ci_image" -f value -c Name)

if [ "$image_exists" == "$ci_image" ]; then
echo "Image $ci_image already exists in OpenStack."
else
echo "Image $ci_image not found in OpenStack. Getting it from S3."

wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/openhpc-images/$ci_image

echo "Uploading image $ci_image to OpenStack..."
openstack image create --file "$ci_image.qcow2" --disk-format qcow2 "$ci_image"

echo "Image $ci_image has been uploaded to OpenStack."
fi
done
41 changes: 41 additions & 0 deletions .github/workflows/upload-release-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

name: Upload release images to client sites from s3
on:
workflow_dispatch:
push:
branches:
- main
- master
- feat/fatimage-auto-upload

jobs:
image_upload:
runs-on: ubuntu-22.04
concurrency: ${{ github.ref }}
env:
OS_CLOUD: openstack
CI_CLOUD: ${{ vars.CI_CLOUD }}
IMAGE_LIST: "RL8 RL9"
steps:
- uses: actions/checkout@v2

- name: Record which cloud CI is running on
run: |
echo CI_CLOUD: ${{ vars.CI_CLOUD }}
- name: Write clouds.yaml
run: |
mkdir -p ~/.config/openstack/
echo "${{ secrets[format('{0}_CLOUDS_YAML', vars.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
shell: bash

- name: Upload latest image if missing
run: |
/usr/bin/python3.10 -m venv venv
. venv/bin/activate
pip install -U pip
pip install -r requirements.txt
ansible --version
. environments/.stackhpc/activate
ansible-galaxy collection install openstack.cloud
. .github/bin/get-s3-image.sh -o

0 comments on commit 0b9a219

Please sign in to comment.