-
Notifications
You must be signed in to change notification settings - Fork 12
153 lines (135 loc) · 4.31 KB
/
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
name: images
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
read-config:
name: Read config
runs-on: ubuntu-latest
outputs:
kernel: ${{ steps.kernel.outputs.config }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read versions.json
id: kernel
run: |
{
echo "config<<EOF"
cat versions.json
echo -e "\nEOF"
} | tee -a "$GITHUB_OUTPUT"
build-and-push:
name: Build And Push
runs-on: ubuntu-latest
needs: read-config
strategy:
matrix:
kernel_version: ${{ fromJSON(needs.read-config.outputs.kernel).versions }}
env:
LATEST_STABLE: ${{ fromJSON(needs.read-config.outputs.kernel).latest_stable }}
LATEST_VERSION: ${{ fromJSON(needs.read-config.outputs.kernel).versions[0] }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache ccache output
uses: actions/cache@v3
with:
path: ccache
key: ccache-${{ matrix.kernel_version }}-${{ hashFiles('config') }}
- name: Inject ccache into builder
uses: reproducible-containers/[email protected]
with:
cache-source: ccache
cache-target: /root/.ccache
- name: Kernel metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/ci-kernels
flavor: latest=false
tags: |
type=raw,value=${{ matrix.kernel_version }}
type=match,pattern=^\d+\.\d+,group=0,value=${{ matrix.kernel_version }}
labels: |
org.opencontainers.image.created=
org.opencontainers.image.revision=
- name: Selftests metadata
id: selftests-meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/ci-kernels
flavor: latest=false
tags: |
type=raw,value=${{ matrix.kernel_version }},suffix=-selftests
type=match,pattern=^\d+\.\d+,group=0,value=${{ matrix.kernel_version }},suffix=-selftests
labels: |
org.opencontainers.image.created=
org.opencontainers.image.revision=
- name: Log in to GitHub Container Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build kernel
uses: docker/build-push-action@v5
with:
target: vmlinux
provenance: false
platforms: |
linux/amd64
${{ matrix.kernel_version == env.LATEST_VERSION && 'linux/arm64' || '' }}
build-args: |
KERNEL_VERSION=${{ matrix.kernel_version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
outputs: ${{ github.ref == 'refs/heads/main' && 'type=registry' || 'type=oci,dest=/tmp/vmlinux.tar' }}
- name: Build selftests
if: matrix.kernel_version == env.LATEST_STABLE
uses: docker/build-push-action@v5
with:
target: selftests-bpf
provenance: false
platforms: |
linux/amd64
build-args: |
KERNEL_VERSION=${{ matrix.kernel_version }}
tags: ${{ steps.selftests-meta.outputs.tags }}
labels: ${{ steps.selftests-meta.outputs.labels }}
annotations: ${{ steps.selftests-meta.outputs.annotations }}
outputs: ${{ github.ref == 'refs/heads/main' && 'type=registry' || 'type=oci,dest=/tmp/selftests-bpf.tar' }}
- name: Store images
if: github.ref != 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: Images (${{ matrix.kernel_version }})
path: '/tmp/*.tar'
retention-days: 1
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Final Results
needs:
- build-and-push
steps:
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}