-
Notifications
You must be signed in to change notification settings - Fork 147
218 lines (210 loc) · 9.21 KB
/
concrete_compiler_publish_docker_images.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: concrete-compiler publish docker images
on:
workflow_dispatch:
push:
branches:
- 'main'
- 'force-docker-images'
env:
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
THIS_FILE: .github/workflows/concrete_compiler_publish_docker_images.yml
concurrency:
group: concrete_compiler_publish_docker_images
cancel-in-progress: true
jobs:
setup-instance:
runs-on: ubuntu-latest
outputs:
runner-name: ${{ steps.start-instance.outputs.label }}
steps:
- name: Start instance
id: start-instance
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
with:
mode: start
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
slab-url: ${{ secrets.SLAB_BASE_URL }}
job-secret: ${{ secrets.JOB_SECRET }}
backend: aws
profile: cpu-test
hpx-image:
needs: [setup-instance]
runs-on: ${{ needs.setup-instance.outputs.runner-name }}
env:
image: ghcr.io/zama-ai/hpx
dockerfile: docker/Dockerfile.hpx-env
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@e9772d140489982e0e3704fea5ee93d536f1e275 # v44.5.24
- name: Login
id: login
if: contains(steps.changed-files.outputs.modified_files, env.dockerfile) || contains(steps.changed-files.outputs.modified_files, env.THIS_FILE)
run: echo "${{ secrets.GHCR_PASSWORD }}" | docker login -u ${{ secrets.GHCR_LOGIN }} --password-stdin ghcr.io
- name: Build
if: ${{ steps.login.conclusion != 'skipped' }}
run: docker build -t "${{ env.image }}" -f ${{ env.dockerfile }} .
# disabled because of https://github.com/aquasecurity/trivy/discussions/7668
# - name: Run Trivy vulnerability scanner
# if: ${{ steps.login.conclusion != 'skipped' }}
# uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0
# with:
# image-ref: '${{ env.IMAGE }}'
# format: 'table'
# exit-code: '1'
# ignore-unfixed: true
# vuln-type: 'os,library'
# severity: 'CRITICAL,HIGH'
- name: Publish
if: ${{ steps.login.conclusion != 'skipped' }}
run: docker push "${{ env.image }}:latest"
- name: Slack Notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
continue-on-error: true
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "hpx-image finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"
cuda-image:
needs: [setup-instance]
runs-on: ${{ needs.setup-instance.outputs.runner-name }}
env:
image: ghcr.io/zama-ai/cuda
strategy:
matrix:
include:
- name: cuda-12-3
tag: 12-3
dockerfile: docker/Dockerfile.cuda-123-env
- name: cuda-11-8
tag: 11-8
dockerfile: docker/Dockerfile.cuda-118-env
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up env
run: |
echo "HOME=/home/ubuntu" >> "${GITHUB_ENV}"
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@e9772d140489982e0e3704fea5ee93d536f1e275 # v44.5.24
- name: Login
id: login
# from the docs: The jobs.<job_id>.if condition is evaluated before jobs.<job_id>.strategy.matrix is applied. So we can't just use matrix.dockerfile
# so we have to build both images if one of the two files change, or we will have to split this into two
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idif
if: contains(steps.changed-files.outputs.modified_files, 'docker/Dockerfile.cuda-118-env') || contains(steps.changed-files.outputs.modified_files, 'docker/Dockerfile.cuda-123-env') || contains(steps.changed-files.outputs.modified_files, env.THIS_FILE)
run: echo "${{ secrets.GHCR_PASSWORD }}" | docker login -u ${{ secrets.GHCR_LOGIN }} --password-stdin ghcr.io
- name: Build Tag and Publish
if: ${{ steps.login.conclusion != 'skipped' }}
run: |
docker build -t "${{ env.image }}" -f ${{ matrix.dockerfile }} .
docker image tag "${{ env.image }}" "${{ env.image }}:${{ matrix.tag }}"
docker push "${{ env.image }}:${{ matrix.tag }}"
# disabled because of https://github.com/aquasecurity/trivy/discussions/7668
# - name: Run Trivy vulnerability scanner
# if: ${{ steps.login.conclusion != 'skipped' }}
# uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0
# with:
# image-ref: '${{ env.image }}'
# format: 'table'
# exit-code: '1'
# ignore-unfixed: true
# vuln-type: 'os,library'
# severity: 'CRITICAL,HIGH'
- name: Push Latest Image
if: ${{ steps.login.conclusion != 'skipped' && matrix.tag == '11-8' }}
run: docker push "${{ env.image }}:latest"
- name: Slack Notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
continue-on-error: true
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "cuda-image finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"
compiler-image:
needs: [setup-instance, hpx-image, cuda-image]
runs-on: ${{ needs.setup-instance.outputs.runner-name }}
env:
image: ghcr.io/zama-ai/concrete-compiler
dockerfile: docker/Dockerfile.concrete-compiler-env
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: recursive
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@e9772d140489982e0e3704fea5ee93d536f1e275 # v44.5.24
with:
files: |
backends/**
compilers/**
third_party/**
tools/**
- name: Login to Registry
id: login
if: steps.changed-files.outputs.any_changed == 'true'
run: echo "${{ secrets.GHCR_PASSWORD }}" | docker login -u ${{ secrets.GHCR_LOGIN }} --password-stdin ghcr.io
- name: Build Image
if: steps.login.conclusion != 'skipped'
run: |
DOCKER_BUILDKIT=1 docker build --no-cache \
--label "commit-sha=${{ github.sha }}" -t ${{ env.image }} -f ${{ env.dockerfile }} .
# disabled because of https://github.com/aquasecurity/trivy/discussions/7668
# - name: Run Trivy vulnerability scanner
# uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0
# with:
# image-ref: '${{ matrix.image }}'
# format: 'table'
# exit-code: '1'
# ignore-unfixed: true
# vuln-type: 'os,library'
# severity: 'CRITICAL,HIGH'
- name: Tag and Publish Image
if: steps.login.conclusion != 'skipped'
run: |
docker image tag ${{ env.image }} ${{ env.image }}:${{ github.sha }}
docker image push ${{ env.image }}:latest
docker image push ${{ env.image }}:${{ github.sha }}
- name: Tag and Publish Release Image
if: steps.login.conclusion != 'skipped' && startsWith(github.ref, 'refs/tags/v')
run: |
docker image tag ${{ env.image }} ${{ env.image }}:${{ github.ref_name }}
docker image push ${{ env.image }}:${{ github.ref_name }}
- name: Slack Notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
continue-on-error: true
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "compiler-image finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"
teardown-instance:
name: Teardown instance
needs: [ setup-instance, compiler-image ]
if: ${{ always() && needs.setup-instance.result != 'skipped' }}
runs-on: ubuntu-latest
steps:
- name: Stop instance
id: stop-instance
uses: zama-ai/slab-github-runner@c0e7168795bd78f61f61146951ed9d0c73c9b701
with:
mode: stop
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
slab-url: ${{ secrets.SLAB_BASE_URL }}
job-secret: ${{ secrets.JOB_SECRET }}
label: ${{ needs.setup-instance.outputs.runner-name }}
- name: Slack Notification
if: ${{ failure() }}
continue-on-error: true
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "Instance teardown finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"