-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd6abef
commit 0b9a219
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |