-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (124 loc) · 4.02 KB
/
docker-build-dev.yml
File metadata and controls
151 lines (124 loc) · 4.02 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
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
name: Build and Push Development Docker Images
on:
push:
branches: [ "main" ]
concurrency:
group: docker
jobs:
build-and-push:
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set lowercase repository name
run: |
echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
- name: Compute version string
run: |
SHA12="${GITHUB_SHA:0:12}"
BRANCH="${GITHUB_REF_NAME}"
if [ -z "${BRANCH}" ]; then
VERSION="dev"
else
VERSION="dev/${BRANCH}@${SHA12}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Build and push Docker image (single arch)
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
push: true
platforms: linux/${{ matrix.arch }}
tags: ghcr.io/${{ env.REPO_LC }}-snapshot:dev-${{ matrix.arch }}
build-args: |
VERSION=${{ env.VERSION }}
manifest:
needs: build-and-push
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set lowercase repository name
run: |
echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
- name: Create and push multi-arch manifest tag
shell: bash
run: |
IMAGE="ghcr.io/${REPO_LC}-snapshot"
docker buildx imagetools create \
-t "${IMAGE}:dev" \
"${IMAGE}:dev-amd64" \
"${IMAGE}:dev-arm64"
docker buildx imagetools inspect "${IMAGE}:dev"
cleanup:
needs: manifest
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
packages: write
steps:
- name: Set lowercase package name
shell: bash
run: |
PACKAGE_NAME=${GITHUB_REPOSITORY##*/}
echo "PACKAGE_NAME_LC=${PACKAGE_NAME,,}" >> $GITHUB_ENV
- name: Clean up untagged (dangling) docker images
uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0
with:
owner: ${{ github.repository_owner }}
package-name: ${{ env.PACKAGE_NAME_LC }}-snapshot
package-type: container
min-versions-to-keep: 10
delete-only-untagged-versions: 'true'
trigger-rollout:
needs: manifest
runs-on: arc-runner-set
timeout-minutes: 10
permissions:
id-token: write
contents: read
steps:
- name: Set lowercase repository name
shell: bash
run: |
echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Trigger rollout
uses: unitvectory-labs/kuberollouttrigger-action@e95cb8eb9a669a16363c13734a3663a7bcca54f2 # v0.2.0
with:
audience: ${{ secrets.KUBEROLLOUTTRIGGER_AUD }}
url: ${{ secrets.KUBEROLLOUTTRIGGER_URL }}
image: ghcr.io/${{ env.REPO_LC }}-snapshot
tags: dev,dev-amd64,dev-arm64