-
Notifications
You must be signed in to change notification settings - Fork 17
216 lines (211 loc) · 7.54 KB
/
docker.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: docker
on:
workflow_call:
inputs:
ref-name:
required: true
type: string
ref-type:
required: true
type: string
secrets:
CI_BOT_APP_ID:
required: true
CI_BOT_PRIVATE_KEY:
required: true
DOCKERHUB_USER:
required: true
DOCKERHUB_TOKEN:
required: true
workflow_dispatch:
inputs:
ref-name:
required: true
type: string
ref-type:
required: true
type: string
env:
MAIN_DISTRO: debian
DEBIAN_CODENAME: bookworm
jobs:
docker:
strategy:
matrix:
distro:
- alpine
- debian
include:
- distro: alpine
platforms: >-
linux/386,
linux/amd64,
linux/arm/v6,
linux/arm/v7,
linux/arm64/v8,
- distro: debian
# docker/setup-*-action has not supported linux/arm/v5.
platforms: >-
linux/386,
linux/amd64,
linux/arm/v7,
linux/arm64/v8,
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref-name }}
- name: Docker tags
id: docker-tags
run: |
IMAGE="{0}" # placeholder
VERSION="${{ inputs.ref-name }}"
MAIN_TAG="$IMAGE:$VERSION-${{ matrix.distro }}"
TAGS="$MAIN_TAG"
if [ "$MAIN_DISTRO" = "${{ matrix.distro }}" ]
then
TAGS="$TAGS,$IMAGE:$VERSION"
fi
if [ "${{ inputs.ref-type }}" = tag ]
then
# Always update latest image tags when a new git tag is created.
TAGS="$TAGS,$IMAGE:${{ matrix.distro }}"
if [ "$MAIN_DISTRO" = "${{ matrix.distro }}" ]; then
TAGS="$TAGS,$IMAGE:latest"
fi
fi
if [ "$VERSION" = main ]
then
TOOLS_TAG=${{ matrix.distro }}
else
MAJOR=$(echo "$VERSION" | cut -d '.' -f 1)
MINOR=$(echo "$VERSION" | cut -d '.' -f 2)
TOOLS_TAG="${{ matrix.distro }}-${MAJOR}.${MINOR}"
fi
echo "Version: $VERSION"
echo "Main tag: $MAIN_TAG"
echo "Tags: $TAGS"
echo "Tools tag: $TOOLS_TAG"
echo "version=$VERSION" >>$GITHUB_OUTPUT
echo "main-tag=$MAIN_TAG" >>$GITHUB_OUTPUT
echo "tags=$TAGS" >>$GITHUB_OUTPUT
echo "tools-tag=$TOOLS_TAG" >>$GITHUB_OUTPUT
- name: Setup QEMU user-mode emulation
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
# See https://github.com/docker/build-push-action/issues/654#issuecomment-1285190151
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 1
- name: Restore cache
uses: actions/cache@v4
with:
path: /tmp/.docker-cache
key: ${{ runner.os }}-docker-cache-${{ matrix.distro }}-${{ hashFiles('**/Cargo.lock', 'docker/build-scripts/*') }}
restore-keys: |
${{ runner.os }}-docker-cache-${{ matrix.distro }}-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (mirakc/mirakc)
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.${{ matrix.distro }}
build-args: |
DEBIAN_CODENAME=${{ env.DEBIAN_CODENAME }}
TOOLS_TAG=${{ steps.docker-tags.outputs.tools-tag }}
target: mirakc
platforms: ${{ matrix.platforms }}
tags: >-
${{ format(steps.docker-tags.outputs.tags, 'docker.io/mirakc/mirakc') }},
cache-from: |
type=local,src=/tmp/.docker-cache
cache-to: |
type=local,dest=/tmp/.docker-cache-new
push: true
- name: Build and push (mirakc/timeshift-fs)
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.${{ matrix.distro }}
build-args: |
DEBIAN_CODENAME=${{ env.DEBIAN_CODENAME }}
TOOLS_TAG=${{ steps.docker-tags.outputs.tools-tag }}
target: mirakc-timeshift-fs
platforms: ${{ matrix.platforms }}
tags: >-
${{ format(steps.docker-tags.outputs.tags, 'docker.io/mirakc/timeshift-fs') }},
cache-from: |
type=local,src=/tmp/.docker-cache-new
cache-to: |
type=local,dest=/tmp/.docker-cache-new
push: true
- name: Test (mirakc/mirakc)
run: |
# Enable experimental CLI features in Docker daemon.
echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
IMG="${{ format(steps.docker-tags.outputs.main-tag, 'mirakc/mirakc') }}"
for PLATFORM in $(echo ${{ matrix.platforms }} | tr ',' ' ')
do
for REG in docker.io
do
echo "Testing $REG/$IMG for $PLATFORM..."
docker run --rm --platform=$PLATFORM $REG/$IMG --version
docker run --rm --platform=$PLATFORM --entrypoint=recdvb $REG/$IMG --version
docker run --rm --platform=$PLATFORM --entrypoint=recpt1 $REG/$IMG --version
docker run --rm --platform=$PLATFORM --entrypoint=mirakc-arib $REG/$IMG --version
docker run --rm --platform=$PLATFORM --entrypoint=mirakc $REG/$IMG --version
docker run --rm --platform=$PLATFORM --entrypoint=dvbv5-zap $REG/$IMG --version
done
done
- name: Test (mirakc/timeshift-fs)
run: |
# Enable experimental CLI features in Docker daemon.
echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
IMG="${{ format(steps.docker-tags.outputs.main-tag, 'mirakc/timeshift-fs') }}"
for PLATFORM in $(echo ${{ matrix.platforms }} | tr ',' ' ')
do
for REG in docker.io
do
echo "Testing $REG/$IMG for $PLATFORM..."
docker run --rm --platform=$PLATFORM --entrypoint=mirakc-timeshift-fs $REG/$IMG --version
done
done
- name: Move cache
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
run: |
rm -rf /tmp/.docker-cache
mv /tmp/.docker-cache-new /tmp/.docker-cache
trigger:
needs:
- docker
runs-on: ubuntu-latest
steps:
# Use the `mirakc-ci` bot account in order to trigger the docker workflow
# on mirakc/docker-timeshift-x.
- uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.CI_BOT_APP_ID }}
private_key: ${{ secrets.CI_BOT_PRIVATE_KEY }}
- name: Trigger the docker workflow on mirakc/docker-timeshift-x
run: |
echo '${{ steps.generate-token.outputs.token }}' | gh auth login --with-token
echo '{"version": "${{ inputs.ref-name }}"}' | gh workflow run docker.yml -R mirakc/docker-timeshift-x --json