-
Notifications
You must be signed in to change notification settings - Fork 26
163 lines (142 loc) · 4.8 KB
/
s3-image-sync.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Upload CI-tested images to Arcus S3 and sync clouds
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'environments/.stackhpc/terraform/cluster_image.auto.tfvars.json'
env:
S3_BUCKET: openhpc-images-prerelease
IMAGE_PATH: environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
jobs:
s3_cleanup:
runs-on: ubuntu-22.04
concurrency: ${{ github.workflow }}-${{ github.ref }}
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Write s3cmd configuration
run: |
echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg
shell: bash
- name: Install s3cmd
run: |
sudo apt-get --yes install s3cmd
- name: Cleanup S3 bucket
run: |
s3cmd rm s3://${{ env.S3_BUCKET }} --recursive --force
image_upload:
runs-on: ubuntu-22.04
needs: s3_cleanup
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build }}
strategy:
fail-fast: false
matrix:
build:
- RL8
- RL9
env:
ANSIBLE_FORCE_COLOR: True
OS_CLOUD: openstack
CI_CLOUD: ${{ vars.CI_CLOUD }}
outputs:
ci_cloud: ${{ steps.ci.outputs.CI_CLOUD }}
steps:
- uses: actions/checkout@v2
- name: Record which cloud CI is running on
id: ci
run: |
echo "CI_CLOUD=${{ env.CI_CLOUD }}" >> "$GITHUB_OUTPUT"
- name: Setup environment
run: |
python3 -m venv venv
. venv/bin/activate
pip install -U pip
pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt)
shell: bash
- name: Write clouds.yaml
run: |
mkdir -p ~/.config/openstack/
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
shell: bash
- name: Write s3cmd configuration
run: |
echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg
shell: bash
- name: Install s3cmd
run: |
sudo apt-get --yes install s3cmd
- name: Retrieve image name
run: |
TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}")
echo "TARGET_IMAGE=${TARGET_IMAGE}" >> "$GITHUB_ENV"
shell: bash
- name: Download image to runner
run: |
. venv/bin/activate
openstack image save --file ${{ env.TARGET_IMAGE }} ${{ env.TARGET_IMAGE }}
shell: bash
- name: Upload Image to S3
run: |
echo "Uploading Image: ${{ env.TARGET_IMAGE }} to S3..."
s3cmd --multipart-chunk-size-mb=150 put ${{ env.TARGET_IMAGE }} s3://${{ env.S3_BUCKET }}
shell: bash
image_sync:
needs: image_upload
runs-on: ubuntu-22.04
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.cloud }}-${{ matrix.build }}
strategy:
fail-fast: false
matrix:
cloud:
- LEAFCLOUD
- SMS
- ARCUS
build:
- RL8
- RL9
exclude:
- cloud: ${{ needs.image_upload.outputs.ci_cloud }}
env:
ANSIBLE_FORCE_COLOR: True
OS_CLOUD: openstack
CI_CLOUD: ${{ matrix.cloud }}
steps:
- uses: actions/checkout@v2
- name: Record which cloud CI is running on
run: |
echo CI_CLOUD: ${{ env.CI_CLOUD }}
- name: Setup environment
run: |
python3 -m venv venv
. venv/bin/activate
pip install -U pip
pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt)
shell: bash
- name: Write clouds.yaml
run: |
mkdir -p ~/.config/openstack/
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
shell: bash
- name: Retrieve image name
run: |
TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}")
echo "TARGET_IMAGE=${TARGET_IMAGE}" >> "$GITHUB_ENV"
- name: Download latest image if missing
run: |
. venv/bin/activate
bash .github/bin/get-s3-image.sh ${{ env.TARGET_IMAGE }} ${{ env.S3_BUCKET }}
- name: Cleanup OpenStack Image (on error or cancellation)
if: cancelled() || failure()
run: |
. venv/bin/activate
image_hanging=$(openstack image list --name ${{ env.TARGET_IMAGE }} -f value -c ID -c Status | grep -v ' active$' | awk '{print $1}')
if [ -n "$image_hanging" ]; then
echo "Cleaning up OpenStack image with ID: $image_hanging"
openstack image delete $image_hanging
else
echo "No image ID found, skipping cleanup."
fi
shell: bash