Skip to content

Feature/helm chart merge (#15) #16

Feature/helm chart merge (#15)

Feature/helm chart merge (#15) #16

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- feature/helm-chart
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ghcr.io/ifrcgo/go-risk-module-api:dev
labels: ${{ steps.meta.outputs.labels }}
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Update Helm chart version and appVersion
run: |
VERSION="1.0.0"
sed -i "s/version:.*/version: ${VERSION}/" helm/go-risk-api/Chart.yaml
sed -i "s/appVersion:.*/appVersion: ${VERSION}/" helm/go-risk-api/Chart.yaml
- name: Update Helm chart image
run: |
REPO="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
REPO="${REPO//\//\\/}" # Escape forward slashes
VERSION="dev"
sed -i "s|repository:.*|repository: ${REPO}|" helm/go-risk-api/values.yaml
sed -i "s/tag:.*/tag: ${VERSION}/" helm/go-risk-api/values.yaml
- name: Package Helm chart
run: helm package helm/go-risk-api
- name: Set short SHA
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Publish Helm chart
run: |
helm plugin install https://github.com/chartmuseum/helm-push
helm repo add --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} chartrepo ${{ env.REGISTRY }}/${{ github.repository_owner }}/charts
helm cm-push go-risk-api-${SHORT_SHA}.tgz chartrepo
- name: Publish Helm chart
run: |
helm plugin install https://github.com/chartmuseum/helm-push
helm repo add --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} chartrepo ${{ env.REGISTRY }}/${{ github.repository_owner }}/charts
helm cm-push ${{ github.event.repository.name }}-${{ github.ref_name }}.tgz chartrepo