6
6
- main
7
7
paths :
8
8
- ' 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
9
12
10
13
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
+
11
35
image_upload :
12
36
runs-on : ubuntu-22.04
37
+ needs : s3_cleanup
13
38
concurrency : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build }}
14
39
strategy :
15
40
fail-fast : false
22
47
ANSIBLE_FORCE_COLOR : True
23
48
OS_CLOUD : openstack
24
49
CI_CLOUD : ${{ vars.CI_CLOUD }}
25
- IMAGE_PATH : environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
26
50
steps :
27
51
- uses : actions/checkout@v2
28
52
@@ -53,37 +77,22 @@ 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
80
+ - name : Retrieve image name
58
81
run : |
59
- . venv/bin/activate
60
82
TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}")
61
83
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
84
shell : bash
74
85
75
86
- name : Download image to runner
76
- if : env.IMAGE_EXISTS == 'false'
77
87
run : |
78
88
. venv/bin/activate
79
89
openstack image save --file ${{ env.TARGET_IMAGE }} ${{ env.TARGET_IMAGE }}
80
90
shell : bash
81
91
82
- - name : Conditionally Upload Image to S3
83
- if : env.IMAGE_EXISTS == 'false'
92
+ - name : Upload Image to S3
84
93
run : |
85
94
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=300 put ${{ env.TARGET_IMAGE }} s3://${{ env.S3_BUCKET }}
87
96
shell : bash
88
97
89
98
image_sync :
@@ -108,7 +117,6 @@ jobs:
108
117
ANSIBLE_FORCE_COLOR : True
109
118
OS_CLOUD : openstack
110
119
CI_CLOUD : ${{ matrix.cloud }}
111
- IMAGE_PATH : environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
112
120
steps :
113
121
- uses : actions/checkout@v2
114
122
@@ -138,7 +146,7 @@ jobs:
138
146
- name : Download latest image if missing
139
147
run : |
140
148
. 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 }}
142
150
143
151
- name : Cleanup OpenStack Image (on error or cancellation)
144
152
if : cancelled()
0 commit comments