-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (184 loc) · 7.23 KB
/
build.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
---
name: build
on:
push:
paths:
- .github/workflows/build.yml
- Dockerfile.alpine
- Dockerfile.debian
- Dockerfile.redhat
pull_request:
paths:
- .github/workflows/build.yml
- Dockerfile.alpine
- Dockerfile.debian
- Dockerfile.redhat
schedule:
- cron: "42 13 * * 1"
jobs:
build:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
name: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
- image: debian-11
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8
- image: debian-12
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: debian-sid
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu-18.04
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu-20.04
dockerfile: Dockerfile.debian
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu-22.04
dockerfile: Dockerfile.debian
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu-24.04
dockerfile: Dockerfile.debian
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: fedora-39
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: fedora-40
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: fedora-41
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: almalinux-8
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: almalinux-9
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: rockylinux-8
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: rockylinux-9
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: alpine-3.17
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine-3.18
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine-3.19
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine-3.20
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine-3.21
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
env:
BASE_IMAGE: ${{ matrix.image }}
DOCKER_DEPLOY_IMAGES: false
steps:
- uses: actions/checkout@v4
- name: Set up env vars
run: |
set -vx
echo "IMG=${BASE_IMAGE}">>$GITHUB_ENV
echo "REPO=docker-ansible">>$GITHUB_ENV
# See: https://github.com/actions/runner-images/issues/9425
- name: Patch crun
shell: bash
run: |
curl -Lo ./crun https://github.com/containers/crun/releases/download/1.14.3/crun-1.14.3-linux-amd64
sudo install crun /usr/bin/crun
- name: Install qemu-user-static
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build images
run: |
podman manifest create ${{ env.REPO }}:${{ env.IMG }}
for arch in $(echo ${{ matrix.platforms }} | sed 's/,/ /g'); do
msg="Build $arch:"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
podman buildx build --tag ${{ env.REPO }}:${{ env.IMG }}-${arch//\//-} \
--platform $arch \
--manifest ${{ env.REPO }}:${{ env.IMG }} \
-f ${{ matrix.dockerfile }} \
--build-arg base_image=${{ matrix.image }}
done
podman images
- name: Push images to local registry
run: |
podman manifest push --tls-verify=0 \
--all ${{ env.REPO }}:${{ env.IMG }} \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }}
- name: Python3 check
run: |
podman run --tls-verify=0 --name python-test --rm -d \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }}
podman exec -it python-test python3 -V
- name: Check GitHub settings
if: >
(github.event_name == 'push' || github.event_name == 'schedule') &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) &&
github.repository == 'fauust/docker-ansible'
run: |
missing=()
[[ -n "${{ secrets.DOCKER_USER }}" ]] || missing+=(DOCKER_USER)
[[ -n "${{ secrets.DOCKER_TOKEN }}" ]] || missing+=(DOCKER_TOKEN)
for i in "${missing[@]}"; do
echo "Missing github secret: $i"
done
(( ${#missing[@]} == 0 )) || exit 1
echo "DOCKER_DEPLOY_IMAGES=true" >> $GITHUB_ENV
- name: Login to ghcr.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images to ghcr.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
run: |
msg="Push docker image to ghcr.io (${{ env.IMG }})"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }} \
docker://ghcr.io/${{ secrets.DOCKER_USER }}/${{ env.REPO }}:${{ env.IMG }}
- name: Login to docker.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push images to docker.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
run: |
msg="Push docker image to docker.io (${{ env.IMG }})"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }} \
docker://docker.io/${{ secrets.DOCKER_USER }}/${{ env.REPO }}:${{ env.IMG }}
- name: Update docker.io description
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
repository: ${{ secrets.DOCKER_USER }}/${{ env.REPO }}
readme-filepath: README.md