mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
218 lines
6.3 KiB
YAML
218 lines
6.3 KiB
YAML
---
|
|
name: "Charts: Release"
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
charts:
|
|
description: >
|
|
Json encoded list of Helm charts to release.
|
|
Defaults to releasing everything.
|
|
default: "[]"
|
|
required: false
|
|
type: string
|
|
excludedChartsRelease:
|
|
description: >
|
|
Json encoded list of Helm charts to exclude from release.
|
|
default: "[]"
|
|
required: false
|
|
type: string
|
|
publishToGhPages:
|
|
description: >
|
|
Should the charts be published to GitHub Pages.
|
|
default: true
|
|
required: false
|
|
type: boolean
|
|
ghPagesBranch:
|
|
description: >
|
|
Target branch for GitHub Pages.
|
|
default: "gh-pages"
|
|
required: false
|
|
type: string
|
|
publishToOciRegistry:
|
|
description: >
|
|
Should the charts be published to an OCI registry.
|
|
default: true
|
|
required: false
|
|
type: boolean
|
|
ociRegistry:
|
|
description: >
|
|
Target OCI registry for Helm charts.
|
|
default: "ghcr.io"
|
|
required: false
|
|
type: string
|
|
helmVersion:
|
|
description: >
|
|
Helm version to use.
|
|
default: "3.11.2"
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
report-changes:
|
|
name: Report changes
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Report changes
|
|
run: |
|
|
echo "Charts to package: ${{ inputs.charts }}"
|
|
|
|
package-charts:
|
|
name: Package charts
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
charts: ${{ fromJSON(inputs.charts) }}
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout source branch
|
|
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: src
|
|
fetch-depth: 0
|
|
|
|
- name: Package Helm charts
|
|
uses: ./src/.github/actions/charts-package
|
|
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
with:
|
|
rootFolder: src/charts
|
|
chartFolder: ${{ matrix.charts }}
|
|
artifactPrefix: chart__
|
|
helmVersion: ${{ inputs.helmVersion }}
|
|
|
|
tag-charts:
|
|
name: Tag charts
|
|
runs-on: ubuntu-22.04
|
|
needs:
|
|
- package-charts
|
|
strategy:
|
|
matrix:
|
|
charts: ${{ fromJSON(inputs.charts) }}
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout source branch
|
|
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Grab chart details
|
|
id: chart-details
|
|
shell: bash
|
|
env:
|
|
ROOT_DIR: charts
|
|
CHART_DIR: "${{ matrix.charts }}"
|
|
run: |
|
|
PARENT_DIR=$(basename $(dirname "${ROOT_DIR}/${CHART_DIR}"))
|
|
echo "name=$(yq '.name' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml)" >> "$GITHUB_OUTPUT"
|
|
echo "version=$(yq '.version' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Create tag
|
|
uses: EndBug/latest-tag@latest
|
|
with:
|
|
ref: ${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}
|
|
|
|
release-charts-to-github-pages:
|
|
name: Release charts to GitHub Pages
|
|
runs-on: ubuntu-22.04
|
|
if: ${{ inputs.publishToGhPages }}
|
|
needs:
|
|
- package-charts
|
|
steps:
|
|
- name: Checkout source branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: src
|
|
|
|
- name: Checkout gh-pages branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ github.token }}
|
|
path: gh-pages
|
|
ref: ${{ inputs.ghPagesBranch }}
|
|
fetch-depth: 0
|
|
|
|
- name: Prepare artifacts for release to GitHub Pages
|
|
uses: ./src/.github/actions/charts-release-ghpages
|
|
with:
|
|
artifactPattern: "*"
|
|
artifactPrefix: chart__
|
|
targetFolder: gh-pages
|
|
targetBranch: gh-pages
|
|
|
|
- name: Publish changes to GitHub Pages
|
|
uses: ./src/.github/actions/publish-folder-to-pages
|
|
with:
|
|
path: gh-pages/
|
|
|
|
prepare-release-charts-to-oci:
|
|
name: Prepare releasing charts to OCI registry
|
|
runs-on: ubuntu-22.04
|
|
if: ${{ inputs.publishToOciRegistry }}
|
|
needs:
|
|
- package-charts
|
|
outputs:
|
|
artifacts: ${{ steps.artifacts.outputs.artifacts }}
|
|
steps:
|
|
- name: List artifacts
|
|
id: list
|
|
uses: yakubique/list-artifacts@v1.1
|
|
with:
|
|
name: chart__*
|
|
|
|
- name: Rewrite artifacts output
|
|
id: artifacts
|
|
shell: bash
|
|
env:
|
|
JQ_COMMAND: |-
|
|
[.[] | {artifact_name: .name, chart_name: (.name | split("__")[-2]), chart_version: (.name | split("__")[-1]) }]
|
|
run: |
|
|
echo '${{ steps.list.outputs.result }}' | jq -c -r "$JQ_COMMAND" > artifacts
|
|
echo "artifacts=$(cat artifacts)" >> "$GITHUB_OUTPUT"
|
|
|
|
release-charts-to-oci:
|
|
name: Release charts to OCI registry
|
|
runs-on: ubuntu-22.04
|
|
if: ${{ inputs.publishToOciRegistry && needs.prepare-release-charts-to-oci.outputs.artifacts != '[]' }}
|
|
strategy:
|
|
matrix:
|
|
artifacts: ${{ fromJSON(needs.prepare-release-charts-to-oci.outputs.artifacts) }}
|
|
fail-fast: false
|
|
needs:
|
|
- package-charts
|
|
- prepare-release-charts-to-oci
|
|
env:
|
|
TARGET_REGISTRY: ghcr.io
|
|
steps:
|
|
- name: Download chart artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
pattern: ${{ matrix.artifacts.artifact_name }}
|
|
|
|
- name: Checkout source branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: src
|
|
|
|
- name: Release chart to OCI registry
|
|
uses: ./src/.github/actions/charts-release-oci
|
|
with:
|
|
workingDir: artifacts/${{ matrix.artifacts.artifact_name }}
|
|
chartName: ${{ matrix.artifacts.chart_name }}
|
|
chartVersion: ${{ matrix.artifacts.chart_version }}
|
|
|
|
cleanup-charts-artifacts:
|
|
name: Clean up artifacts
|
|
runs-on: ubuntu-22.04
|
|
needs:
|
|
- package-charts
|
|
- release-charts-to-github-pages
|
|
- release-charts-to-oci
|
|
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
|
|
steps:
|
|
- name: Clean up artifact
|
|
uses: joernott/rm-artifact@v1
|
|
with:
|
|
name: "*"
|
|
useGlob: true
|
|
failOnError: true
|