Skip to content

test: test image build with chart release #4

test: test image build with chart release

test: test image build with chart release #4

###############################################################
# Copyright (c) 2024 BMW Group AG
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
name: Release
on:
workflow_dispatch:
push:
paths:
- 'charts/**'
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME_SERVICE: ${{ github.repository }}_dim-service
IMAGE_NAME_MIGRATIONS: ${{ github.repository }}_dim-migrations
IMAGE_NAME_WORKER: ${{ github.repository }}_dim-processes-worker
jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@b7246b12e77f7134dc2d460a3d5bad15bbe29390 # v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update helm dependencies for dim
run: |
cd charts/dim
helm repo add bitnami https://charts.bitnami.com/bitnami
helm dependency update
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_SKIP_EXISTING: "true"
- name: Get current helm chart version
id: chart-version
run: |
current=$(cat ./charts/dim/Chart.yaml | grep "version:" | head -1 | cut -d ":" -d " " -f2)
echo "current=$current" >> $GITHUB_OUTPUT
echo "Exported $current helm chart version"
- name: Check for previous version
id: version-check
run: |
exists=$(git tag -l "v${{ steps.chart-version.outputs.current }}")
if [[ -n "$exists" ]]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: steps.version-check.outputs.exists == 'false'

Check failure on line 95 in .github/workflows/chart-release.yaml

View workflow run for this annotation

GitHub Actions / Release

Invalid workflow file

The workflow is not valid. .github/workflows/chart-release.yaml (Line: 95, Col: 9): 'if' is already defined
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0
if: steps.version-check.outputs.exists == 'false'
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
if: steps.version-check.outputs.exists == 'false'
# Create SemVer or ref tags dependent of trigger event
- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: |
${{ env.REGISTRY}}/${{ env.IMAGE_NAME_SERVICE }}
# Automatically prepare image tags; See action docs for more examples.
# semver patter will generate tags like these for example :1 :1.2 :1.2.3
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest
type=semver,pattern={{version}},value=${{ steps.chart-version.outputs.current }}
type=semver,pattern={{major}},value=${{ steps.chart-version.outputs.current }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.chart-version.outputs.current }}
if: steps.version-check.outputs.exists == 'false'
- name: Build and push Docker image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
context: .
file: docker/Dockerfile-dim-service
platforms: linux/amd64, linux/arm64
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
if: steps.version-check.outputs.exists == 'false'