Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Build SecretsManagement-Operator Release Dockerimage #6

Build SecretsManagement-Operator Release Dockerimage

Build SecretsManagement-Operator Release Dockerimage #6

name: Build SecretsManagement-Operator Release Dockerimage
run-name: Build SecretsManagement-Operator Release Dockerimage
on:
push:
jobs:
build-secrets-management-operator-release-dockerfile-job:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: read image of secretsmanagement-operator from values.yaml
id: get_smanop_image
uses: mikefarah/yq@master
with:
cmd: yq '.secretsmanagement-operator.image' charts/canvas-oda/values.yaml
- name: read versionnumber of secretsmanagement-operator from values.yaml
id: get_smanop_version
uses: mikefarah/yq@master
with:
cmd: yq '[.secretsmanagement-operator.version, .secretsmanagement-operator.prereleaseSuffix] | filter(.!=null and .!="") | join("-")' charts/canvas-oda/values.yaml
- name: Check Version
id: check-tag
run: |
echo
if [[ ${{ steps.get_smanop_version.outputs.result }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version ${{ steps.get_smanop_version.outputs.result }} matches release format <n>.<n>.<n>"
else
echo "::error::Version ${{ steps.get_smanop_version.outputs.result }} does not match release format <n>.<n>.<n>" && exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Check for already existing image tag
id: check_docker_image
uses: KerberosMorphy/[email protected]
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
image: ${{ steps.get_smanop_image.outputs.result }}:${{ steps.get_smanop_version.outputs.result }}
- name: error if tag already exists
if: steps.check_docker_image.outputs.image_exist==1
run: |
echo "::error::image tag ${{ steps.get_smanop_version.outputs.result }} already exists in repo ${{ steps.get_smanop_image.outputs.result }}, exiting!" && exit 2
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Git commit timestamps
run: |
echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "CICD_BUILD_TIME=$(date -Iseconds)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
context: source/operators/secretsmanagementOperator-hc/docker
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
GIT_COMMIT_SHA=${{ env.GIT_COMMIT_SHA }}
CICD_BUILD_TIME=${{ env.CICD_BUILD_TIME }}
# arm64 has problems building cffi python wheel
#platforms: linux/amd64,linux/arm64
platforms: linux/amd64
push: true
tags: |
${{ steps.get_smanop_image.outputs.result }}:latest
${{ steps.get_smanop_image.outputs.result }}:${{ steps.get_smanop_version.outputs.result }}
env:
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}