Skip to content

k8ssandra-client build for external calls #95

k8ssandra-client build for external calls

k8ssandra-client build for external calls #95

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_image:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets[format('{0}', inputs.tokenSecret)] }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: azure/setup-helm@v3
if: ${{ env.ACT }}
with:
version: '3.13.1'
id: install
- name: Set up QEMU
if: ${{ !env.ACT }}
uses: docker/setup-qemu-action@v2
- name: Login to DockerHub
if: ${{ !env.ACT }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Create release name
id: vars
run: |
echo "tag=${{ inputs.chartName }}-${{ inputs.chartVersion }}" >> $GITHUB_OUTPUT
- 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: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
load: false
file: cmd/kubectl-k8ssandra/Dockerfile
push: ${{ github.event_name != 'pull_request' && !env.ACT }}
tags: k8ssandra/k8ssandra-client:${{ steps.vars.outputs.tag }}
platforms: linux/amd64,linux/arm64
context: .
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache