-
Notifications
You must be signed in to change notification settings - Fork 658
108 lines (97 loc) · 3.19 KB
/
ci-image.yml
File metadata and controls
108 lines (97 loc) · 3.19 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
name: Build CI Image
on:
push:
branches: [main]
paths:
- 'deploy/docker/Dockerfile.ci'
- 'mise.toml'
- 'mise.lock'
- 'tasks/**'
- '.github/workflows/ci-image.yml'
workflow_dispatch:
env:
REGISTRY: ghcr.io
CI_IMAGE: ghcr.io/nvidia/openshell/ci
permissions:
contents: read
packages: write
jobs:
build-ci-image:
name: Build (${{ matrix.arch }})
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: linux-amd64-cpu8
- arch: arm64
platform: linux/arm64
runner: linux-arm64-cpu8
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve BuildKit config
id: buildkit
run: |
if [[ -r /etc/buildkit/buildkitd.toml ]]; then
echo "config=/etc/buildkit/buildkitd.toml" >> "$GITHUB_OUTPUT"
else
echo "config=" >> "$GITHUB_OUTPUT"
fi
- name: Set up Docker Buildx
uses: ./.github/actions/setup-buildx
with:
buildkitd-config: ${{ steps.buildkit.outputs.config }}
- name: Build and push CI image
env:
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARCH_IMAGE: ${{ env.CI_IMAGE }}:${{ github.sha }}-${{ matrix.arch }}
run: |
set -euo pipefail
docker buildx build \
--builder openshell \
--platform "${{ matrix.platform }}" \
--secret id=MISE_GITHUB_TOKEN,env=MISE_GITHUB_TOKEN \
--cache-from "type=gha,scope=ci-image-${{ matrix.arch }}" \
--cache-to "type=gha,mode=max,scope=ci-image-${{ matrix.arch }}" \
--push \
-t "$ARCH_IMAGE" \
-f deploy/docker/Dockerfile.ci \
.
- name: Smoke check CI image
env:
ARCH_IMAGE: ${{ env.CI_IMAGE }}:${{ github.sha }}-${{ matrix.arch }}
run: |
set -euo pipefail
docker run --rm --platform "${{ matrix.platform }}" "$ARCH_IMAGE" mise --version
docker run --rm --platform "${{ matrix.platform }}" "$ARCH_IMAGE" gh --version
docker run --rm --platform "${{ matrix.platform }}" "$ARCH_IMAGE" docker buildx version
merge-ci-image:
name: Merge manifest
needs: build-ci-image
runs-on: linux-amd64-cpu8
timeout-minutes: 10
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-arch manifests
run: |
set -euo pipefail
docker buildx imagetools create \
--prefer-index=false \
-t "${CI_IMAGE}:${GITHUB_SHA}" \
-t "${CI_IMAGE}:latest" \
"${CI_IMAGE}:${GITHUB_SHA}-amd64" \
"${CI_IMAGE}:${GITHUB_SHA}-arm64"