Skip to content

Commit

Permalink
flux artifact pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkoSekulic committed Jul 15, 2024
1 parent c89baa5 commit e7cdebb
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/flux-artifact-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Eid logger helm config build and push
on:
push:
branches: [ main ]
paths:
- 'eidlogger/**'
- '.github/workflows/flux-artifact-push.yaml'
- '.deploy/eid-logger/**'
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
helm-build-push:
name: Flux config push
runs-on: ubuntu-latest
strategy:
matrix:
environment: [staging]
env:
REGISTRY: altinntjenestercontainerregistry.azurecr.io
REPOSITORY: eid-logger
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID_FC }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID_FC }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: 'Azure login'
uses: azure/login@v2
with:
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}

- name: 'Install helm'
uses: azure/[email protected]
with:
version: '3.15.3'
id: install

- name: Log in to Container registry
run: |
az acr login --name ${{ env.REGISTRY }} --expose-token --output tsv --query accessToken --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }} --only-show-errors | docker login ${{ env.REGISTRY }} --username 00000000-0000-0000-0000-000000000000 --password-stdin
- name: Setup Flux CLI
uses: fluxcd/flux2/[email protected]

- name: Install Flux
run: |
flux install
- name: Generate cofiguration file
run: |
mkdir eid-logger-config
helm template eid-logger-config --set gitSha=${{ github.sha }} > eid-logger-config/helm-release.yaml
- name: Push config artifact
run: |
flux push artifact oci://${{ env.REGISTRY }}/charts/configs/eid-logger-${{ matrix.environment }}:${{ github.sha }} \
--path="./eid-logger-config" \
--source="$(git config --get remote.origin.url)" \
--revision="$(git branch --show-current)/$(git rev-parse HEAD)"
- name: Tag artifact as latest
run: |
flux tag artifact oci://${{ env.REGISTRY }}/charts/configs/eid-logger-${{ matrix.environment }}:${{ github.sha }} --tag latest
24 changes: 24 additions & 0 deletions charts/eid-logger-config/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: eid-logger
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
27 changes: 27 additions & 0 deletions charts/eid-logger-config/templates/helm-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: eid-logger
namespace: default
spec:
releaseName: eid-logger
targetNamespace: default
interval: 5m
install:
remediation:
retries: 1
upgrade:
remediation:
retries: 1
chart:
spec:
version: "{{ .Values.gitSha }}"
chart: eid-logger
sourceRef:
kind: HelmRepository
name: eid-logger
namespace: default
values:
image:
tag: "{{ .Values.gitSha }}"
1 change: 1 addition & 0 deletions charts/eid-logger-config/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gitSha: "placeholder"

0 comments on commit e7cdebb

Please sign in to comment.