-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (113 loc) · 3.34 KB
/
ci.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
name: CI
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
permissions:
packages: write
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build (${{ matrix.variant.platform }})
runs-on:
group: ${{ matrix.variant.builder }}
container:
image: ghcr.io/zephyrproject-rtos/image-build:v1.0.0
strategy:
fail-fast: true
matrix:
variant:
- platform: linux/amd64
arch: amd64
builder: zephyr-runner-v2-linux-x64-4xlarge
- platform: linux/arm64
arch: arm64
builder: zephyr-runner-v2-linux-arm64-4xlarge
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/zephyrproject-rtos/ci-repo-cache
flavor: |
latest=false
suffix=-${{ matrix.variant.arch }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: redhat-actions/podman-login@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: redhat-actions/buildah-build@v2
with:
context: .
containerfiles: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Push image
if: ${{ github.event_name != 'pull_request' }}
uses: redhat-actions/push-to-registry@v2
with:
tags: ${{ steps.meta.outputs.tags }}
merge:
name: Merge
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/image-build:v1.0.0
needs: build
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Login to GitHub Container Registry
uses: redhat-actions/podman-login@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/zephyrproject-rtos/ci-repo-cache
flavor: |
latest=false
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Create multi-architecture image
run: |
archs=(amd64 arm64)
image="ghcr.io/zephyrproject-rtos/ci-repo-cache:${{ steps.meta.outputs.version }}"
image_tags="${{ steps.meta.outputs.tags }}"
# Pull architecture-specific image.
for arch in ${archs[@]}; do
podman pull ${image}-${arch}
done
# Create multi-architecture image.
for arch in ${archs[@]}; do
image_amend_flags+="--amend ${image}-${arch} "
done
podman manifest create ${image} ${image_amend_flags}
# Create image tags.
for tag in ${image_tags}; do
podman tag ${image} ${tag}
done
- name: Push image
uses: redhat-actions/push-to-registry@v2
with:
tags: ${{ steps.meta.outputs.tags }}