-
Notifications
You must be signed in to change notification settings - Fork 23
165 lines (144 loc) · 5.29 KB
/
kubectl-shell.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
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
name: "kubectl-shell"
on:
workflow_dispatch:
push:
branches:
- 'develop'
- 'release/*'
paths:
- 'kubectl-shell/**'
pull_request:
types:
- 'opened'
- 'reopened'
- 'synchronize'
- 'ready_for_review'
branches:
- 'develop'
- 'release/*'
paths:
- 'kubectl-shell/**'
env:
DOCKER_HUB_REPO: portainerci/kubectl-shell
jobs:
build_images:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
config:
- { platform: linux, arch: amd64 }
- { platform: linux, arch: arm64 }
- { platform: linux, arch: arm }
- { platform: linux, arch: ppc64le }
steps:
- name: "[preparation] checkout"
uses: actions/checkout@v4.1.1
- name: "[preparation] set up qemu"
uses: docker/setup-qemu-action@v3.2.0
- name: "[preparation] set up docker context for buildx"
run: docker context create builders
- name: "[preparation] set up docker buildx"
uses: docker/setup-buildx-action@v3.6.1
with:
endpoint: builders
driver-opts: image=moby/buildkit:v0.10.6
- name: "[preparation] docker login"
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: "[metadata] generate image tags"
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.DOCKER_HUB_REPO }}
- name: "[build] build and push by digest"
id: build
uses: docker/build-push-action@v6.7.0
with:
context: kubectl-shell/
platforms: ${{ matrix.config.platform }}/${{ matrix.config.arch }}
build-args: |
HELM_VERSION=v3.15.4
KUBERNETES_RELEASE=v1.31.0
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
outputs: type=image,name=${{ env.DOCKER_HUB_REPO }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
sbom: false
provenance: false
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
- name: "[build] export digest"
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: "[build] upload digest"
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.config.platform }}-${{ matrix.config.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
build_manifests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [build_images]
steps:
- name: "[preparation] download digests"
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: "[preparation] setup manifest name"
run: |
if [[ "${GITHUB_REF_NAME}" =~ ^release/.*$ ]]; then
# use the release branch name as the tag for release branches
# for instance, release/2.19 becomes 2.19
CONTAINER_IMAGE_TAG=$(echo $GITHUB_REF_NAME | cut -d "/" -f 2)
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
# use pr${{ github.event.number }} as the tag for pull requests
# for instance, pr123
CONTAINER_IMAGE_TAG="pr${{ github.event.number }}"
else
# replace / with - in the branch name
# for instance, feature/1.0.0 -> feature-1.0.0
CONTAINER_IMAGE_TAG=$(echo $GITHUB_REF_NAME | sed 's/\//-/g')
fi
# export the tag to the environment
echo "CONTAINER_IMAGE_TAG=${CONTAINER_IMAGE_TAG}" >> $GITHUB_ENV
- name: "[metadata] generate image tags"
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.DOCKER_HUB_REPO }}
tags: |
type=raw,value=${{ env.CONTAINER_IMAGE_TAG }}
- name: "[preparation] set up docker context for buildx"
run: docker context create builders
- name: "[preparation] set up docker buildx"
uses: docker/setup-buildx-action@v3.0.0
with:
endpoint: builders
driver-opts: image=moby/buildkit:v0.10.6
- name: "[preparation] docker login"
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: "[build] create manifest list and push"
working-directory: /tmp/digests
run: |
docker manifest create ${{ env.DOCKER_HUB_REPO }}:${{ steps.meta.outputs.version }} \
$(printf '${{ env.DOCKER_HUB_REPO }}@sha256:%s ' *)
docker manifest push ${{ env.DOCKER_HUB_REPO }}:${{ steps.meta.outputs.version }}
- name: "[validate] inspect image"
run: |
docker buildx imagetools inspect ${{ env.DOCKER_HUB_REPO }}:${{ steps.meta.outputs.version }}