Skip to content

Commit 3c8985d

Browse files
authored
Changed workflow to use matrix (#105)
Signed-off-by: Roland Asmann <roland.asmann@gmail.com>
1 parent 409c342 commit 3c8985d

File tree

1 file changed

+26
-88
lines changed

1 file changed

+26
-88
lines changed

.github/workflows/containers.yml

Lines changed: 26 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ env:
2020
jobs:
2121
deploy:
2222
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 }}
2631
permissions:
2732
contents: write
2833
packages: write
@@ -51,6 +56,7 @@ jobs:
5156
with:
5257
node-version: '23.x'
5358
- uses: oras-project/setup-oras@v1
59+
if: matrix.image.arch == 'amd64'
5460
- name: Trim CI agent
5561
run: |
5662
chmod +x ci/free_disk_space.sh
@@ -73,13 +79,15 @@ jobs:
7379
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7480
SCALAPY_PYTHON_LIBRARY: "python3.12"
7581
- name: Export python requirements
82+
if: matrix.image.arch == 'amd64'
7683
run: |
7784
python3.12 -m pip install --upgrade pip setuptools
7885
python3.12 -m pip install poetry
7986
python3.12 -m poetry self add poetry-plugin-export
8087
python3.12 -m poetry export -f requirements.txt --with=science --without-hashes --output target/chen-science-requirements.txt
8188
python3.12 -m poetry export -f requirements.txt --with=database --without-hashes --output target/chen-database-requirements.txt
8289
- name: Upload chen to ghcr
90+
if: matrix.image.arch == 'amd64'
8391
run: |
8492
cd target
8593
echo $GITHUB_TOKEN | oras login ghcr.io -u $GITHUB_USERNAME --password-stdin
@@ -107,103 +115,29 @@ jobs:
107115
with:
108116
images: |
109117
ghcr.io/appthreat/chen
110-
flavor: latest=false,suffix=-amd64
118+
flavor: latest=false,suffix=-${{ matrix.image.arch }}
111119
- name: Build and push Docker images
112120
uses: docker/build-push-action@v5
113121
id: build
114122
with:
115123
file: ci/Dockerfile
116124
context: .
117-
platforms: linux/amd64
125+
platforms: linux/${{ matrix.image.arch }}
118126
push: true
119127
tags: ${{ steps.meta.outputs.tags }}
120128
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
195131
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 }}
202136
203137
deploy-manifest:
204138
if: github.repository_owner == 'appthreat'
205139
runs-on: ubuntu-24.04
206-
needs: [deploy, deploy-arm]
140+
needs: [deploy]
207141
outputs:
208142
image-uri: ghcr.io/appthreat/chen@${{ steps.build.outputs.digest }}
209143
permissions:
@@ -222,11 +156,15 @@ jobs:
222156
id: metadata
223157
with:
224158
images: ghcr.io/${{ github.repository }}
159+
- uses: cloudposse/github-action-matrix-outputs-read@v1
160+
id: read
161+
with:
162+
matrix-step-name: deploy
225163
- uses: int128/docker-manifest-create-action@v2
226164
id: build
227165
with:
228166
index-annotations: ${{ steps.metadata.outputs.labels }}
229167
tags: ${{ steps.metadata.outputs.tags }}
230168
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

Comments
 (0)