|
6 | 6 | - main
|
7 | 7 | paths:
|
8 | 8 | - 'environments/.stackhpc/terraform/cluster_image.auto.tfvars.json'
|
| 9 | +env: |
| 10 | + S3_BUCKET: openhpc-images-prerelease |
9 | 11 |
|
10 | 12 | 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 | +
|
11 | 34 | image_upload:
|
12 | 35 | runs-on: ubuntu-22.04
|
| 36 | + needs: s3_cleanup |
13 | 37 | concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build }}
|
14 | 38 | strategy:
|
15 | 39 | fail-fast: false
|
@@ -53,37 +77,16 @@ jobs:
|
53 | 77 | run: |
|
54 | 78 | sudo apt-get --yes install s3cmd
|
55 | 79 |
|
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 |
| - |
75 | 80 | - name: Download image to runner
|
76 |
| - if: env.IMAGE_EXISTS == 'false' |
77 | 81 | run: |
|
78 | 82 | . venv/bin/activate
|
79 | 83 | openstack image save --file ${{ env.TARGET_IMAGE }} ${{ env.TARGET_IMAGE }}
|
80 | 84 | shell: bash
|
81 | 85 |
|
82 |
| - - name: Conditionally Upload Image to S3 |
83 |
| - if: env.IMAGE_EXISTS == 'false' |
| 86 | + - name: Upload Image to S3 |
84 | 87 | run: |
|
85 | 88 | 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 }} |
87 | 90 | shell: bash
|
88 | 91 |
|
89 | 92 | image_sync:
|
@@ -138,7 +141,7 @@ jobs:
|
138 | 141 | - name: Download latest image if missing
|
139 | 142 | run: |
|
140 | 143 | . 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 }} |
142 | 145 |
|
143 | 146 | - name: Cleanup OpenStack Image (on error or cancellation)
|
144 | 147 | if: cancelled()
|
|
0 commit comments