-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (101 loc) · 3.3 KB
/
vaccel-build-and-upload.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
name: Build QEMU+vAccel docker image
on:
push:
branches: [ '*\+vaccel' ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
REGISTRY: harbor.nbfc.io/nubificus
IMAGE_NAME: qemu-vaccel
APP: qemu-vaccel
jobs:
build:
name: Build Docker Image
runs-on: [self-hosted, gcc, lite, "${{ matrix.arch }}"]
strategy:
matrix:
arch: [x86_64, aarch64]
outputs:
digest-x86_64: ${{ steps.set-outputs.outputs.digest-x86_64 }}
digest-aarch64: ${{ steps.set-outputs.outputs.digest-aarch64 }}
steps:
- name: Cleanup previous jobs
run: |
echo "Cleaning up previous runs"
sudo rm -rf ${{ github.workspace }}/*
sudo rm -rf ${{ github.workspace }}/.??*
- name: Checkout code
uses: actions/checkout@v4
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.HARBOR_USER }}
password: ${{ secrets.HARBOR_PASSWD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.arch }}
type=sha,prefix=${{ matrix.arch }}-
type=sha,format=long,prefix=${{ matrix.arch }}-
type=ref,event=branch,prefix=${{ matrix.arch }}-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: ./subprojects/vaccel/docker
no-cache: true
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ARCHTAG=${{ matrix.arch }}
BRANCH=${{ github.event.ref_name || github.ref_name }}
- name: Set per-arch outputs
id: set-outputs
run: |
# Workaround for https://github.com/actions/runner/issues/2499
echo "digest-${{ matrix.arch }}=${{ steps.build-and-push.outputs.digest }}" \
>> "$GITHUB_OUTPUT"
sign:
name: Sign Docker Image
runs-on: [self-hosted]
needs: [build]
strategy:
matrix:
arch: [x86_64, aarch64]
permissions:
contents: read
id-token: write
steps:
- name: Install Cosign
uses: sigstore/[email protected]
- name: Check install
run: cosign version
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.HARBOR_USER }}
password: ${{ secrets.HARBOR_PASSWD }}
- name: Sign published Docker image
env:
DIGEST: ${{ needs.build.outputs[format('digest-{0}', matrix.arch)] }}
run: |
cosign sign --yes ${{ env.REGISTRY }}/${{ env.APP }}@${{ env.DIGEST }} \
-a "repo=${{ github.repository }}" \
-a "workflow=${{ github.workflow }}" \
-a "ref=${{ github.sha }}" \
-a "author=Nubificus LTD"
- name: Cleanup previous runs
if: ${{ always() }}
run: |
sudo rm -rf ${{ github.workspace }}/*
sudo rm -rf ${{ github.workspace }}/.??*