20
20
jobs :
21
21
deploy :
22
22
if : github.repository_owner == 'appthreat'
23
- runs-on : ubuntu-24.04
24
- outputs :
25
- image-uri : ghcr.io/appthreat/chen@${{ steps.build.outputs.digest }}
23
+ strategy :
24
+ fail-fast : true
25
+ matrix :
26
+ image :
27
+ - arch : amd64
28
+ - arch : arm64
29
+ runner-suffix : -arm
30
+ runs-on : ubuntu-24.04${{ matrix.image.runner-suffix }}
26
31
permissions :
27
32
contents : write
28
33
packages : write
51
56
with :
52
57
node-version : ' 23.x'
53
58
- uses : oras-project/setup-oras@v1
59
+ if : matrix.image.arch == 'amd64'
54
60
- name : Trim CI agent
55
61
run : |
56
62
chmod +x ci/free_disk_space.sh
@@ -73,13 +79,15 @@ jobs:
73
79
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74
80
SCALAPY_PYTHON_LIBRARY: "python3.12"
75
81
- name : Export python requirements
82
+ if : matrix.image.arch == 'amd64'
76
83
run : |
77
84
python3.12 -m pip install --upgrade pip setuptools
78
85
python3.12 -m pip install poetry
79
86
python3.12 -m poetry self add poetry-plugin-export
80
87
python3.12 -m poetry export -f requirements.txt --with=science --without-hashes --output target/chen-science-requirements.txt
81
88
python3.12 -m poetry export -f requirements.txt --with=database --without-hashes --output target/chen-database-requirements.txt
82
89
- name : Upload chen to ghcr
90
+ if : matrix.image.arch == 'amd64'
83
91
run : |
84
92
cd target
85
93
echo $GITHUB_TOKEN | oras login ghcr.io -u $GITHUB_USERNAME --password-stdin
@@ -107,103 +115,29 @@ jobs:
107
115
with :
108
116
images : |
109
117
ghcr.io/appthreat/chen
110
- flavor : latest=false,suffix=-amd64
118
+ flavor : latest=false,suffix=-${{ matrix.image.arch }}
111
119
- name : Build and push Docker images
112
120
uses : docker/build-push-action@v5
113
121
id : build
114
122
with :
115
123
file : ci/Dockerfile
116
124
context : .
117
- platforms : linux/amd64
125
+ platforms : linux/${{ matrix.image.arch }}
118
126
push : true
119
127
tags : ${{ steps.meta.outputs.tags }}
120
128
labels : ${{ steps.meta.outputs.labels }}
121
-
122
- deploy-arm :
123
- if : github.repository_owner == 'appthreat'
124
- runs-on : ubuntu-24.04-arm
125
- outputs :
126
- image-uri : ghcr.io/appthreat/chen@${{ steps.build.outputs.digest }}
127
- permissions :
128
- contents : write
129
- packages : write
130
- steps :
131
- - uses : actions/checkout@v4
132
- with :
133
- fetch-depth : 0
134
- - name : Set up JDK
135
- uses : actions/setup-java@v4
136
- with :
137
- distribution : ' temurin'
138
- java-version : ' 21'
139
- - uses : sbt/setup-sbt@v1
140
- - name : " Install PHP"
141
- uses : " shivammathur/setup-php@v2"
142
- with :
143
- coverage : " none"
144
- php-version : " 8.3"
145
- tools : composer:v2
146
- - name : Set up Python
147
- uses : actions/setup-python@v5
148
- with :
149
- python-version : ' 3.12'
150
- - name : Use Node.js
151
- uses : actions/setup-node@v4
152
- with :
153
- node-version : ' 23.x'
154
- - name : Trim CI agent
155
- run : |
156
- chmod +x ci/free_disk_space.sh
157
- ./ci/free_disk_space.sh
158
- - name : Delete `.rustup` directory
159
- run : rm -rf /home/runner/.rustup # to save disk space
160
- if : runner.os == 'Linux'
161
- - name : Delete `.cargo` directory # to save disk space
162
- run : rm -rf /home/runner/.cargo
163
- if : runner.os == 'Linux'
164
- - uses : actions/cache@v4
165
- with :
166
- path : |
167
- ~/.sbt
168
- ~/.coursier
169
- key : ${{ runner.os }}-sbt-${{ hashfiles('**/build.sbt') }}
170
- - run : |
171
- sbt stage createDistribution
172
- env:
173
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174
- SCALAPY_PYTHON_LIBRARY: "python3.12"
175
- - name : Set up QEMU
176
- uses : docker/setup-qemu-action@v3
177
- - name : Set up Docker Buildx
178
- uses : docker/setup-buildx-action@v3
179
- - name : Log in to the Container registry
180
- uses : docker/login-action@v3
181
- with :
182
- registry : ghcr.io
183
- username : ${{ github.actor }}
184
- password : ${{ secrets.GITHUB_TOKEN }}
185
- - name : Extract metadata (tags, labels) for Docker
186
- id : meta
187
- uses : docker/metadata-action@v5
188
- with :
189
- images : |
190
- ghcr.io/appthreat/chen
191
- flavor : latest=false,suffix=-arm64
192
- - name : Build and push Docker images
193
- uses : docker/build-push-action@v5
194
- id : build
129
+ - uses : cloudposse/github-action-matrix-outputs-write@v1
130
+ id : out
195
131
with :
196
- file : ci/Dockerfile
197
- context : .
198
- platforms : linux/arm64
199
- push : true
200
- tags : ${{ steps.meta.outputs.tags }}
201
- labels : ${{ steps.meta.outputs.labels }}
132
+ matrix-step-name : deploy
133
+ matrix-key : ${{ matrix.image.arch }}
134
+ outputs : |-
135
+ image-uri: ghcr.io/appthreat/chen@${{ steps.build.outputs.digest }}
202
136
203
137
deploy-manifest :
204
138
if : github.repository_owner == 'appthreat'
205
139
runs-on : ubuntu-24.04
206
- needs : [deploy, deploy-arm ]
140
+ needs : [deploy]
207
141
outputs :
208
142
image-uri : ghcr.io/appthreat/chen@${{ steps.build.outputs.digest }}
209
143
permissions :
@@ -222,11 +156,15 @@ jobs:
222
156
id : metadata
223
157
with :
224
158
images : ghcr.io/${{ github.repository }}
159
+ - uses : cloudposse/github-action-matrix-outputs-read@v1
160
+ id : read
161
+ with :
162
+ matrix-step-name : deploy
225
163
- uses : int128/docker-manifest-create-action@v2
226
164
id : build
227
165
with :
228
166
index-annotations : ${{ steps.metadata.outputs.labels }}
229
167
tags : ${{ steps.metadata.outputs.tags }}
230
168
sources : |
231
- ${{ needs.deploy .outputs.image-uri }}
232
- ${{ needs.deploy-arm .outputs.image-uri }}
169
+ ${{ fromJSON(steps.read .outputs.result). image-uri.amd64 }}
170
+ ${{ fromJSON(steps.read .outputs.result). image-uri.arm64 }}
0 commit comments