Merge pull request #52 from sic-applied-ai/merge-to-develop #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation | |
# | |
# 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: Build and push the latest build to staging | |
on: | |
push: | |
branches: [ develop ] | |
workflow_dispatch: | |
branches: [ develop ] | |
env: | |
NAMESPACE: "ingress-custodian" | |
SECRET: "acr-credentials" | |
CLUSTER_RESOURCE_GROUP: "cxtsi-dev013-rg" | |
CLUSTER_NAME: "cxtsi-dev013-aks-services" | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
if: ${{ false }} # disable for now | |
steps: | |
# Checks out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
- uses: madhead/read-java-properties@latest | |
id: version | |
with: | |
file: gradle.properties | |
property: version | |
default: 0.0.1 | |
- name: Set App Version | |
run: echo "APP_VERSION=${{ steps.version.outputs.value }}" >> $GITHUB_ENV | |
- name: Set outputs | |
id: vars | |
run: | | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Show version | |
run: echo ${APP_VERSION}.${SHORT_SHA} | |
- name: Docker Login | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ secrets.CX_ACR_SERVER }} | |
username: ${{ secrets.CX_ACR_USER }} | |
password: ${{ secrets.CX_ACR_PASSWORD }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 | |
with: | |
arguments: build | |
- name: Create dist | |
uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 | |
with: | |
arguments: installDist | |
- name: Build and push staging images | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
tags: ${{ secrets.CX_ACR_SERVER }}/catena-x/custodian:${{ env.APP_VERSION }}.${{ env.SHORT_SHA }} | |
push: true | |
deploy: | |
needs: build | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: madhead/read-java-properties@latest | |
id: version | |
with: | |
file: gradle.properties | |
property: version | |
default: 0.0.1 | |
- name: Set App Version | |
run: echo "APP_VERSION=${{ steps.version.outputs.value }}" >> $GITHUB_ENV | |
- name: Install Helm | |
uses: Azure/setup-helm@v1 | |
with: | |
version: v3.3.1 | |
- name: Set the target Azure Kubernetes Service (AKS) cluster. | |
uses: azure/aks-set-context@v1 | |
with: | |
creds: '${{ secrets.AZURE_SP_DEV013_TSI }}' | |
cluster-name: ${{ env.CLUSTER_NAME }} | |
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} | |
- name: Create namespace if doesn't exist | |
run: | | |
kubectl create namespace ${{ env.NAMESPACE }} --dry-run=client -o json | kubectl apply -f - | |
- name: Create image pull secret for ACR | |
uses: azure/k8s-create-secret@v1 | |
with: | |
container-registry-url: ${{ secrets.CX_ACR_SERVER }} | |
container-registry-username: ${{ secrets.CX_ACR_USER }} | |
container-registry-password: ${{ secrets.CX_ACR_PASSWORD }} | |
secret-name: ${{ env.SECRET }} | |
namespace: ${{ env.NAMESPACE }} | |
arguments: --force true | |
- name: Set outputs | |
id: vars | |
run: | | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Package Helm App version and Chart | |
run: | | |
helm package --app-version=${APP_VERSION} --version=${APP_VERSION} ./helm/custodian | |
- name: Run Helm Deploy app to dev | |
run: | | |
helm upgrade \ | |
--install \ | |
--atomic \ | |
--wait \ | |
--namespace ${{ env.NAMESPACE }} \ | |
cx-custodian catenax-custodian-${APP_VERSION}.tgz \ | |
-f ./helm/custodian/values-staging.yaml \ | |
--set image.registry=${{ secrets.CX_ACR_SERVER }} \ | |
--set image.tag=${APP_VERSION}.${SHORT_SHA} \ | |
--set app.version=${APP_VERSION} \ | |
--set certificate.host="custodian-dev.germanywestcentral.cloudapp.azure.com" |