-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (113 loc) · 4.32 KB
/
ci.yaml
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
name: docker
on:
push:
branches:
- main
pull_request: ~
release:
types:
- published
env:
REPOSITORY: 'ghcr.io/s6n-labs/docker-runner-images'
APT_UBUNTU_MIRROR: 'http://jp.ports.ubuntu.com/ubuntu-ports/'
jobs:
build:
permissions:
contents: read
packages: write
strategy:
matrix:
os:
- ubuntu-22.04
- ubuntu-23.04
architecture:
- ARM64
- X64
include:
- architecture: ARM64
platforms: linux/arm64/v8
runner: buildjet-4vcpu-ubuntu-2204-arm
suffix: arm64
- architecture: X64
platforms: linux/amd64
runner: buildjet-4vcpu-ubuntu-2204
suffix: amd64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GHCR
run: echo "${{ github.token }}" | docker login ghcr.io -u $ --password-stdin
- name: Get shorter hash of the commit
id: shorter_hash
run: echo "hash=$(echo ${GITHUB_SHA} | cut -c1-7)" >> ${GITHUB_OUTPUT}
- name: Build (minimal)
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
provenance: false
file: './${{ matrix.os }}/Dockerfile'
target: 'minimal'
build-args: 'APT_UBUNTU_MIRROR=${{ env.APT_UBUNTU_MIRROR }}'
tags: |
${{ env.REPOSITORY }}:${{ matrix.os }}-minimal-${{ steps.shorter_hash.outputs.hash }}-${{ matrix.suffix }}
${{ env.REPOSITORY }}:${{ matrix.os }}-minimal-${{ github.event.release.tag_name || 'latest' }}-${{ matrix.suffix }}
${{ env.REPOSITORY }}:${{ matrix.os }}-minimal-${{ matrix.suffix }}
- name: Build (standard)
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
provenance: false
file: './${{ matrix.os }}/Dockerfile'
target: 'standard'
build-args: 'APT_UBUNTU_MIRROR=${{ env.APT_UBUNTU_MIRROR }}'
tags: |
${{ env.REPOSITORY }}:${{ matrix.os }}-standard-${{ steps.shorter_hash.outputs.hash }}-${{ matrix.suffix }}
${{ env.REPOSITORY }}:${{ matrix.os }}-standard-${{ github.event.release.tag_name || 'latest' }}-${{ matrix.suffix }}
${{ env.REPOSITORY }}:${{ matrix.os }}-standard-${{ matrix.suffix }}
- name: Build (dind)
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
provenance: false
file: './${{ matrix.os }}/Dockerfile'
target: 'dind'
build-args: 'APT_UBUNTU_MIRROR=${{ env.APT_UBUNTU_MIRROR }}'
tags: |
${{ env.REPOSITORY }}:${{ matrix.os }}-dind-${{ steps.shorter_hash.outputs.hash }}-${{ matrix.suffix }}
${{ env.REPOSITORY }}:${{ matrix.os }}-dind-${{ github.event.release.tag_name || 'latest' }}-${{ matrix.suffix }}
${{ env.REPOSITORY }}:${{ matrix.os }}-dind-${{ matrix.suffix }}
outputs:
shorter_hash: '${{ steps.shorter_hash.outputs.hash }}'
combine:
needs:
- build
permissions:
contents: read
packages: write
strategy:
matrix:
os:
- ubuntu-22.04
- ubuntu-23.04
variant:
- minimal
- standard
- dind
runs-on: ubuntu-22.04
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Log in to GHCR
run: echo "${{ github.token }}" | docker login ghcr.io -u $ --password-stdin
- name: Determine the prefix of tags
id: tag_prefix
run: |
echo "commitish=${REPOSITORY}:${{ matrix.os }}-${{ matrix.variant }}-${{ needs.build.outputs.shorter_hash }}" >> "${GITHUB_OUTPUT}"
echo "versioned=${REPOSITORY}:${{ matrix.os }}-${{ matrix.variant }}-${{ github.event.release.tag_name || 'latest' }}" >> "${GITHUB_OUTPUT}"
- name: Create and push multi-arch image manifests
run: |
for TAG in '${{ steps.tag_prefix.outputs.commitish }}' '${{ steps.tag_prefix.outputs.versioned }}'; do
docker manifest create "${TAG}" --amend "${TAG}-amd64" --amend "${TAG}-arm64"
docker manifest push "${TAG}"
done