Skip to content

fix operator docker image build error #108

fix operator docker image build error

fix operator docker image build error #108

#
# Copyright 2021 - now, the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Operator Docker
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Build & Push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.2
name: Checkout
- name: Prepare Variables
id: prepare
run: |
DOCKER_IMAGE=monime/zookeeper-operator
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest"
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.20
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Dependencies
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- uses: docker/build-push-action@v2
name: Build and Deploy
with:
push: true
file: deployments/docker/operator/Dockerfile
tags: ${{ steps.prepare.outputs.tags }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.version=${{ steps.prepare.outputs.version }}
org.opencontainers.image.created=${{ steps.prepare.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Build Helm and Manifest
id: helm
run: |
git config --global pull.ff only
git clone https://.:${{ secrets.GITHUB_TOKEN }}@github.com/monimesl/helm-charts.git output
TAG=${{ steps.prepare.outputs.version }}
deployments/charts/build-helm.sh $TAG output
helm repo index --url https://monimesl.github.io/helm-charts/ output --merge output/index.yaml
echo ::set-output name=tag::${TAG}
- name: Index Helm Chart
uses: cpina/github-action-push-to-another-repository@main
with:
source-directory: 'output'
destination-github-username: 'monimesl'
destination-repository-name: 'helm-charts'
user-email: shawalpha5@gmail.com
target-branch: main
env:
API_TOKEN_GITHUB: ${{ secrets.ACCESS_TOKEN_GITHUB }}
- name: Update Readme
run: |
LATEST_TAG=${{ steps.helm.outputs.tag }}
sed -i "s|__latest_tag__|$LATEST_TAG|" README.md
- name: Commit Manifests
uses: EndBug/add-and-commit@v7
with:
message: "🤖 - CI bot add install manifests and update README.md"
add: "deployments/manifest.yaml README.md"
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}