Skip to content

Commit 03d7180

Browse files
committed
Create matrix for monitors
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
1 parent c713481 commit 03d7180

2 files changed

Lines changed: 174 additions & 105 deletions

File tree

.github/workflows/build_changed_images.yml

Lines changed: 61 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242
echo "Files in hello-world: ${{ steps.filter.outputs.hello-world_files }}"
4343
echo "Changes: ${{ steps.filter.outputs.changes }}"
4444
45-
build-image:
46-
name: Build and push image
45+
for-KVM-based-monitors:
46+
name: Build changed apps
4747
needs: get-changed-files
4848
if: |
4949
needs.get-changed-files.outputs.hello-world_files != '' &&
@@ -53,109 +53,65 @@ jobs:
5353
)
5454
strategy:
5555
matrix:
56-
include:
57-
- arch: amd64
58-
runner: ubuntu-22.04
59-
- arch: arm64
60-
runner: ubuntu-22.04-arm
61-
runs-on: ${{ matrix.runner }}
62-
steps:
63-
- name: Checkout code
64-
uses: actions/checkout@v4
65-
with:
66-
fetch-depth: 0
67-
68-
- name: Set short SHA
69-
run: echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
70-
71-
- name: Set up Docker Buildx
72-
uses: docker/setup-buildx-action@v3
73-
74-
- name: Log into registry ${{ env.REGISTRY }}
75-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
76-
with:
77-
registry: ${{ env.REGISTRY }}
78-
username: ${{ github.actor }}
79-
password: ${{ secrets.GITHUB_TOKEN }}
80-
81-
- name: Extract Docker metadata
82-
id: meta
83-
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
84-
with:
85-
images: ${{ env.REGISTRY }}/${{ github.repository }}/hello-world-${{ env.monitor }}-${{ env.framework }}
86-
tags: |
87-
type=sha,prefix=${{ matrix.arch }}-,format=long
88-
89-
- name: Build and push
90-
id: build-and-push
91-
uses: docker/build-push-action@v6
92-
with:
93-
context: ./hello-world/${{ env.framework }}
94-
tags: ${{ steps.meta.outputs.tags }}
95-
labels: ${{ steps.meta.outputs.labels }}
96-
platforms: linux/${{ matrix.arch }}
97-
push: true
98-
provenance: false
99-
file: ./hello-world/${{ env.framework }}/bunnyfile-${{ env.monitor }}-${{ matrix.arch }}
100-
101-
create-manifest:
102-
needs: [build-image]
103-
runs-on: ubuntu-22.04
104-
steps:
105-
106-
- name: Install Cosign
107-
uses: sigstore/cosign-installer@v3.4.0
108-
109-
- name: Check install!
110-
run: cosign version
111-
112-
- name: Log into registry ${{ env.REGISTRY }}
113-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
114-
with:
115-
registry: ${{ env.REGISTRY }}
116-
username: ${{ github.actor }}
117-
password: ${{ secrets.GITHUB_TOKEN }}
118-
119-
- name: Extract Docker metadata
120-
id: meta
121-
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051
122-
with:
123-
images: ${{ env.REGISTRY }}/${{ github.repository }}/hello-world-${{ env.monitor }}-${{ env.framework }}
124-
tags: |
125-
type=sha,prefix=,format=long
126-
127-
- name: Create manifest
128-
run: |
129-
TAGS=${{ steps.meta.outputs.tags }}
130-
IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/hello-world-${{ env.monitor }}-${{ env.framework }}
131-
docker manifest rm $TAGS || true
132-
docker manifest create $TAGS \
133-
--amend ${IMAGE}:amd64-${{ steps.meta.outputs.tag-names }} \
134-
--amend ${IMAGE}:arm64-${{ steps.meta.outputs.tag-names }}
135-
HASH=$(docker manifest push $TAGS)
136-
echo "hash=$HASH" >> $GITHUB_ENV
137-
echo "tags=$TAGS" >> $GITHUB_ENV
138-
139-
- name: Sign the published Docker image
140-
env:
141-
COSIGN_EXPERIMENTAL: "true"
142-
DIGEST: ${{ env.hash }}
143-
TAGS: ${{ env.tags }}
144-
run: |
145-
cosign sign --yes ${{ env.REGISTRY_IMAGE }}@${{ env.DIGEST }} \
146-
-a "repo=${{github.repository}}" \
147-
-a "workflow=${{github.workflow}}" \
148-
-a "ref=${{github.sha}}" \
149-
-a "author=urunc-dev/unikernel-build"
150-
151-
## for-each-changed-app:
152-
## name: Build changed apps
56+
monitor: [qemu, firecracker]
57+
##apps: ${{ fromJSON(needs.get-chnaged-files.outputs.apps) }}
58+
uses: ./.github/workflows/build_images.yml
59+
with:
60+
monitor: ${{ matrix.monitor }}
61+
secrets: inherit
62+
63+
## build-image:
64+
## name: Build and push image
15365
## needs: get-changed-files
66+
## if: |
67+
## needs.get-changed-files.outputs.hello-world_files != '' &&
68+
## (
69+
## contains(needs.get-changed-files.outputs.hello-world_files, 'src') ||
70+
## contains(needs.get-changed-files.outputs.hello-world_files, 'unikraft')
71+
## )
15472
## strategy:
15573
## matrix:
156-
## apps: ${{ fromJSON(needs.get-chnaged-files.outputs.apps) }}
157-
## uses: ./.github/workflows/build_push_unikernels.yml
158-
## with:
159-
## app: ${{ matrix.apps }}
160-
## changed: ${{ needs.get-chnaged-files.outputs[ format('{0}_files', matrix.apps) ] }}
161-
## secrets: inherit
74+
## include:
75+
## - arch: amd64
76+
## runner: ubuntu-22.04
77+
## - arch: arm64
78+
## runner: ubuntu-22.04-arm
79+
## runs-on: ${{ matrix.runner }}
80+
## steps:
81+
## - name: Checkout code
82+
## uses: actions/checkout@v4
83+
## with:
84+
## fetch-depth: 0
85+
##
86+
## - name: Set short SHA
87+
## run: echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
88+
##
89+
## - name: Set up Docker Buildx
90+
## uses: docker/setup-buildx-action@v3
91+
##
92+
## - name: Log into registry ${{ env.REGISTRY }}
93+
## uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
94+
## with:
95+
## registry: ${{ env.REGISTRY }}
96+
## username: ${{ github.actor }}
97+
## password: ${{ secrets.GITHUB_TOKEN }}
98+
##
99+
## - name: Extract Docker metadata
100+
## id: meta
101+
## uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
102+
## with:
103+
## images: ${{ env.REGISTRY }}/${{ github.repository }}/hello-world-${{ env.monitor }}-${{ env.framework }}
104+
## tags: |
105+
## type=sha,prefix=${{ matrix.arch }}-,format=long
106+
##
107+
## - name: Build and push
108+
## id: build-and-push
109+
## uses: docker/build-push-action@v6
110+
## with:
111+
## context: ./hello-world/${{ env.framework }}
112+
## tags: ${{ steps.meta.outputs.tags }}
113+
## labels: ${{ steps.meta.outputs.labels }}
114+
## platforms: linux/${{ matrix.arch }}
115+
## push: true
116+
## provenance: false
117+
## file: ./hello-world/${{ env.framework }}/bunnyfile-${{ env.monitor }}-${{ matrix.arch }}

.github/workflows/build_images.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Build unikernel and single application kernel images
2+
3+
on:
4+
workflow_all:
5+
inputs:
6+
monitor:
7+
description: "The target monitor for the unikernel or single application kernel"
8+
type: string
9+
required: true
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
framework: unikraft
14+
15+
jobs:
16+
build-image:
17+
name: Build and push image
18+
strategy:
19+
matrix:
20+
include:
21+
- arch: amd64
22+
runner: ubuntu-22.04
23+
- arch: arm64
24+
runner: ubuntu-22.04-arm
25+
runs-on: ${{ matrix.runner }}
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set short SHA
33+
run: echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
38+
- name: Log into registry ${{ env.REGISTRY }}
39+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Extract Docker metadata
46+
id: meta
47+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ github.repository }}/hello-world-${{ inputs.monitor }}-${{ env.framework }}
50+
tags: |
51+
type=sha,prefix=${{ matrix.arch }}-,format=long
52+
53+
- name: Build and push
54+
id: build-and-push
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: ./hello-world/${{ env.framework }}
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
platforms: linux/${{ matrix.arch }}
61+
push: true
62+
provenance: false
63+
file: ./hello-world/${{ env.framework }}/bunnyfile-${{ inputs.monitor }}-${{ matrix.arch }}
64+
65+
create-manifest:
66+
needs: [build-image]
67+
runs-on: ubuntu-22.04
68+
steps:
69+
70+
- name: Install Cosign
71+
uses: sigstore/cosign-installer@v3.4.0
72+
73+
- name: Check install!
74+
run: cosign version
75+
76+
- name: Log into registry ${{ env.REGISTRY }}
77+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
78+
with:
79+
registry: ${{ env.REGISTRY }}
80+
username: ${{ github.actor }}
81+
password: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- name: Extract Docker metadata
84+
id: meta
85+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051
86+
with:
87+
images: ${{ env.REGISTRY }}/${{ github.repository }}/hello-world-${{ inputs.monitor }}-${{ env.framework }}
88+
tags: |
89+
type=sha,prefix=,format=long
90+
91+
- name: Create manifest
92+
run: |
93+
TAGS=${{ steps.meta.outputs.tags }}
94+
IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/hello-world-${{ inputs.monitor }}-${{ env.framework }}
95+
docker manifest rm $TAGS || true
96+
docker manifest create $TAGS \
97+
--amend ${IMAGE}:amd64-${{ steps.meta.outputs.tag-names }} \
98+
--amend ${IMAGE}:arm64-${{ steps.meta.outputs.tag-names }}
99+
HASH=$(docker manifest push $TAGS)
100+
echo "hash=$HASH" >> $GITHUB_ENV
101+
echo "tags=$TAGS" >> $GITHUB_ENV
102+
103+
##- name: Sign the published Docker image
104+
## env:
105+
## COSIGN_EXPERIMENTAL: "true"
106+
## DIGEST: ${{ env.hash }}
107+
## TAGS: ${{ env.tags }}
108+
## run: |
109+
## cosign sign --yes ${{ env.REGISTRY_IMAGE }}@${{ env.DIGEST }} \
110+
## -a "repo=${{github.repository}}" \
111+
## -a "workflow=${{github.workflow}}" \
112+
## -a "ref=${{github.sha}}" \
113+
## -a "author=urunc-dev/unikernel-build"

0 commit comments

Comments
 (0)