Repository navigation
124 lines (107 loc) · 3.6 KB
/
Copy pathdocker.yml
File metadata and controls
124 lines (107 loc) · 3.6 KB
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
name: docker
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1
jobs:
smoke:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
arch: amd64
- platform: linux/arm64
arch: arm64
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up QEMU
if: matrix.arch == 'arm64'
uses: docker/setup-qemu-action@v4
with:
platforms: arm64
- name: Pull BuildKit with retry
run: bash scripts/ci-pull-image.sh "$BUILDKIT_IMAGE"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
driver-opts: image=${{ env.BUILDKIT_IMAGE }}
- name: Build ${{ matrix.platform }} smoke image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.platform }}
load: true
push: false
tags: vocat-smoke:${{ matrix.arch }}
build-args: |
VERSION=0.0.0-smoke
BUILD_TIME=${{ github.event.repository.updated_at }}
cache-from: type=gha
- name: Verify ${{ matrix.platform }} runtime, QMI, and smart-card stack
run: |
docker run --rm --platform '${{ matrix.platform }}' \
vocat-smoke:${{ matrix.arch }} version
docker run --rm --platform '${{ matrix.platform }}' \
--entrypoint /bin/sh vocat-smoke:${{ matrix.arch }} -c \
'command -v qmicli && command -v qmi-network && command -v pcscd && test -d /usr/lib/pcsc/drivers'
build-and-push:
needs: smoke
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Lowercase repository owner for ghcr.io
id: repo
run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Derive version from tag
id: version
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.0-dev" >> "$GITHUB_OUTPUT"
fi
echo "build_time=$(git show -s --format=%cI HEAD)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: arm64
- name: Pull BuildKit with retry
run: bash scripts/ci-pull-image.sh "$BUILDKIT_IMAGE"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
driver-opts: image=${{ env.BUILDKIT_IMAGE }}
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push multi-arch image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
VERSION=${{ steps.version.outputs.version }}
BUILD_TIME=${{ steps.version.outputs.build_time }}
tags: |
${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:latest
${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max