Skip to content

Publish Helm Chart #5163

Publish Helm Chart

Publish Helm Chart #5163

Workflow file for this run

# SPDX-FileCopyrightText: Copyright 2023 The Minder Authors
# SPDX-License-Identifier: Apache-2.0
# Post-submit and daily build and publish of the Helm chart and Docker container
# This is a separate workflow than image-build.yml because image-build.yml is
# run in the PR context, and those runs aren't allowed package:write permissions if
# the source is a fork(GitHub errors and invalidates the entire workflow if you try).
name: Publish Helm Chart
on:
push:
branches:
- main
schedule:
# Weekdays at noon GMT
- cron: '00 12 * * 1-5'
jobs:
check-helm:
name: Build Helm chart
runs-on: ubuntu-latest
if: github.repository_owner == 'mindersec' || vars.PUBLISH_IMAGES == 'true'
permissions:
contents: read
packages: write
id-token: write # To sign the provenance.
env:
BASE_REPO: "ghcr.io/${{ github.repository }}"
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: 'go.mod'
- uses: ko-build/setup-ko@61b4d1d396f5b2e7d6bb6fefdce3dc38d1a13445 # v0.10
with:
version: v0.16.0
- uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: v3.12.2
- name: Compute version number
id: version-string
run: |
DATE="$(date +%Y%m%d)"
COMMIT="$(git rev-parse --short HEAD)"
echo "tag=0.$DATE.$GITHUB_RUN_NUMBER+ref.$COMMIT" >> "$GITHUB_OUTPUT"
- name: Build images and Helm Chart
run: |
KO_DOCKER_REPO=$BASE_REPO make helm
echo "Built images:"
cat deployment/helm/built-images.yaml
env:
KO_PUSH_IMAGE: "true"
HELM_PACKAGE_VERSION: "${{ steps.version-string.outputs.tag }}"
- name: Helm Login
# ko can pick up tokens ambiently from the GitHub Actions environment, but
# Helm needs explicit login
run: |
helm registry login $BASE_REPO --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }}
- name: Push Helm Chart
id: helm-push
run: |
cd deployment/helm
helm push minder-*.tgz oci://$BASE_REPO/helm 2>&1 | tee helm-push.log
DIGEST=$(grep Digest: helm-push.log | awk '{print $2}')
echo "Helm chart digest: $DIGEST"
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
- name: Sign the published helm chart and ko image
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: |
# Sign the ko image
cosign sign --yes $(cat deployment/helm/built-images.yaml)
# Sign the helm chart
cosign sign --yes $BASE_REPO/helm/minder@${{ steps.helm-push.outputs.digest }}