-
Notifications
You must be signed in to change notification settings - Fork 7
146 lines (146 loc) · 5.72 KB
/
tools-release.yaml
File metadata and controls
146 lines (146 loc) · 5.72 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
name: k8ssandra-client build for external calls
on:
workflow_dispatch:
inputs:
chartName:
description: 'Name of the chart to be embedded in the image'
required: true
type: string
chartVersion:
description: 'Target version to upgrade CRDs to. If used with git, give the tag name'
required: true
type: string
repoName:
description: 'Name of the Helm repository if not default'
required: false
type: string
repoURL:
description: 'URL of the target repository if repoName is set'
required: false
type: string
gitRepo:
description: 'git repository to be embedded in the image'
required: false
type: string
chartDir:
description: 'Directory of the chart in the git repository to be embedded in the image'
required: false
type: string
tokenSecret:
description: 'Secret name to be used as GitHub token if gitRepo is set'
required: false
type: string
jobs:
create_the_images:
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
env:
GH_TOKEN: ${{ secrets[format('{0}', inputs.tokenSecret)] }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
k8ssandra/k8ssandra-client
tags: |
type=raw,value=${{ inputs.chartName }}-${{ inputs.chartVersion }}
- name: Download the requested charts
if: ${{ !inputs.gitRepo }}
id: download_charts
run: |
if [ -z "${{ inputs.tokenSecret }}" ]; then
helm repo add ${{ inputs.repoName }} ${{ inputs.repoURL }}
else
helm repo add ${{ inputs.repoName }} ${{ inputs.repoURL }} --username "${{ env.GH_TOKEN }}" --password "${{ env.GH_TOKEN }}"
fi
helm repo update
helm pull ${{ inputs.repoName }}/${{ inputs.chartName }} --version ${{ inputs.chartVersion }}
mkdir -p build/${{ inputs.repoName }}
tar -xvf ${{ inputs.chartName }}-${{ inputs.chartVersion }}.tgz -C build/${{ inputs.repoName }}
- name: Download the requested chart from another repository
if: ${{ inputs.gitRepo }}
id: download_charts_github
run: |
gh repo clone ${{ inputs.gitRepo }} ${{ inputs.repoName }}
cd ${{ inputs.repoName }}
git checkout ${{ inputs.chartVersion }}
cd ..
mkdir -p build/${{ inputs.repoName }}
cp -R ${{ inputs.repoName }}/${{ inputs.chartDir }}/* build/${{ inputs.repoName }}
helm dependency update build/${{ inputs.repoName }}
- name: Prepare Dockerfile requirements
id: vars
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
file: cmd/kubectl-k8ssandra/Dockerfile
platforms: ${{ matrix.platform }}
context: .
tags: k8ssandra/k8ssandra-client
push: ${{ github.event_name != 'pull_request' }}
outputs: type=image,push-by-digest=true,name-canonical=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.docker_build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v5
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge_the_images:
runs-on: ubuntu-latest
needs:
- create_the_images
steps:
- name: Download digests
uses: actions/download-artifact@v6
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
k8ssandra/k8ssandra-client
tags: |
type=raw,value=${{ inputs.chartName }}-${{ inputs.chartVersion }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'k8ssandra/k8ssandra-client@sha256:%s ' *)