Skip to content

Commit 87b26cc

Browse files
committed
cleanup s3 at beginning
1 parent f16a871 commit 87b26cc

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

.github/workflows/fatimage.yml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,34 @@ on:
66
- main
77
paths:
88
- 'environments/.stackhpc/terraform/cluster_image.auto.tfvars.json'
9+
env:
10+
S3_BUCKET: openhpc-images-prerelease
911

1012
jobs:
13+
s3_cleanup:
14+
runs-on: ubuntu-22.04
15+
concurrency: ${{ github.workflow }}-${{ github.ref }}
16+
strategy:
17+
fail-fast: false
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Write s3cmd configuration
22+
run: |
23+
echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg
24+
shell: bash
25+
26+
- name: Install s3cmd
27+
run: |
28+
sudo apt-get --yes install s3cmd
29+
30+
- name: Cleanup S3 bucket
31+
run: |
32+
s3cmd rm s3://${{ env.S3_BUCKET }} --recursive --force
33+
1134
image_upload:
1235
runs-on: ubuntu-22.04
36+
needs: s3_cleanup
1337
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build }}
1438
strategy:
1539
fail-fast: false
@@ -53,37 +77,16 @@ jobs:
5377
run: |
5478
sudo apt-get --yes install s3cmd
5579
56-
- name: Check for image in Arcus S3 bucket
57-
id: s3_ls
58-
run: |
59-
. venv/bin/activate
60-
TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}")
61-
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
73-
shell: bash
74-
7580
- name: Download image to runner
76-
if: env.IMAGE_EXISTS == 'false'
7781
run: |
7882
. venv/bin/activate
7983
openstack image save --file ${{ env.TARGET_IMAGE }} ${{ env.TARGET_IMAGE }}
8084
shell: bash
8185

82-
- name: Conditionally Upload Image to S3
83-
if: env.IMAGE_EXISTS == 'false'
86+
- name: Upload Image to S3
8487
run: |
8588
echo "Uploading Image: ${{ env.TARGET_IMAGE }} to S3..."
86-
s3cmd --multipart-chunk-size-mb=300 put ${{ env.TARGET_IMAGE }} s3://openhpc-images-prerelease
89+
s3cmd --multipart-chunk-size-mb=300 put ${{ env.TARGET_IMAGE }} s3://${{ env.S3_BUCKET }}
8790
shell: bash
8891

8992
image_sync:
@@ -138,7 +141,7 @@ jobs:
138141
- name: Download latest image if missing
139142
run: |
140143
. venv/bin/activate
141-
bash .github/bin/get-s3-image.sh ${{ env.TARGET_IMAGE }} openhpc-images-prerelease
144+
bash .github/bin/get-s3-image.sh ${{ env.TARGET_IMAGE }} ${{ env.S3_BUCKET }}
142145
143146
- name: Cleanup OpenStack Image (on error or cancellation)
144147
if: cancelled()

0 commit comments

Comments
 (0)