Skip to content

Commit 75188f7

Browse files
committed
cleanup s3 at beginning
1 parent f16a871 commit 75188f7

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

.github/workflows/fatimage.yml

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,35 @@ on:
66
- main
77
paths:
88
- 'environments/.stackhpc/terraform/cluster_image.auto.tfvars.json'
9+
env:
10+
S3_BUCKET: openhpc-images-prerelease
11+
IMAGE_PATH: environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
912

1013
jobs:
14+
s3_cleanup:
15+
runs-on: ubuntu-22.04
16+
concurrency: ${{ github.workflow }}-${{ github.ref }}
17+
strategy:
18+
fail-fast: false
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Write s3cmd configuration
23+
run: |
24+
echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg
25+
shell: bash
26+
27+
- name: Install s3cmd
28+
run: |
29+
sudo apt-get --yes install s3cmd
30+
31+
- name: Cleanup S3 bucket
32+
run: |
33+
s3cmd rm s3://${{ env.S3_BUCKET }} --recursive --force
34+
1135
image_upload:
1236
runs-on: ubuntu-22.04
37+
needs: s3_cleanup
1338
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build }}
1439
strategy:
1540
fail-fast: false
@@ -22,7 +47,6 @@ jobs:
2247
ANSIBLE_FORCE_COLOR: True
2348
OS_CLOUD: openstack
2449
CI_CLOUD: ${{ vars.CI_CLOUD }}
25-
IMAGE_PATH: environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
2650
steps:
2751
- uses: actions/checkout@v2
2852

@@ -53,37 +77,22 @@ jobs:
5377
run: |
5478
sudo apt-get --yes install s3cmd
5579
56-
- name: Check for image in Arcus S3 bucket
57-
id: s3_ls
80+
- name: Retrieve image name
5881
run: |
59-
. venv/bin/activate
6082
TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}")
6183
echo "TARGET_IMAGE=${TARGET_IMAGE}" >> "$GITHUB_ENV"
62-
echo "target-image-${{ matrix.build }}=${TARGET_IMAGE}" >> "$GITHUB_OUTPUT"
63-
64-
S3_IMAGES=$(s3cmd ls s3://openhpc-images-prerelease)
65-
66-
if echo "$S3_IMAGES" | grep -q "$TARGET_IMAGE"; then
67-
echo "Image ${TARGET_IMAGE} is already present in S3."
68-
echo "IMAGE_EXISTS=true" >> $GITHUB_ENV
69-
else
70-
echo "Image ${TARGET_IMAGE} is not present in S3."
71-
echo "IMAGE_EXISTS=false" >> $GITHUB_ENV
72-
fi
7384
shell: bash
7485

7586
- name: Download image to runner
76-
if: env.IMAGE_EXISTS == 'false'
7787
run: |
7888
. venv/bin/activate
7989
openstack image save --file ${{ env.TARGET_IMAGE }} ${{ env.TARGET_IMAGE }}
8090
shell: bash
8191

82-
- name: Conditionally Upload Image to S3
83-
if: env.IMAGE_EXISTS == 'false'
92+
- name: Upload Image to S3
8493
run: |
8594
echo "Uploading Image: ${{ env.TARGET_IMAGE }} to S3..."
86-
s3cmd --multipart-chunk-size-mb=300 put ${{ env.TARGET_IMAGE }} s3://openhpc-images-prerelease
95+
s3cmd --multipart-chunk-size-mb=150 put ${{ env.TARGET_IMAGE }} s3://${{ env.S3_BUCKET }}
8796
shell: bash
8897

8998
image_sync:
@@ -108,7 +117,6 @@ jobs:
108117
ANSIBLE_FORCE_COLOR: True
109118
OS_CLOUD: openstack
110119
CI_CLOUD: ${{ matrix.cloud }}
111-
IMAGE_PATH: environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
112120
steps:
113121
- uses: actions/checkout@v2
114122

@@ -138,7 +146,7 @@ jobs:
138146
- name: Download latest image if missing
139147
run: |
140148
. venv/bin/activate
141-
bash .github/bin/get-s3-image.sh ${{ env.TARGET_IMAGE }} openhpc-images-prerelease
149+
bash .github/bin/get-s3-image.sh ${{ env.TARGET_IMAGE }} ${{ env.S3_BUCKET }}
142150
143151
- name: Cleanup OpenStack Image (on error or cancellation)
144152
if: cancelled()

0 commit comments

Comments
 (0)