mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
160 lines
5.8 KiB
YAML
160 lines
5.8 KiB
YAML
---
|
|
name: "Charts: Release"
|
|
|
|
concurrency: helm-release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
charts:
|
|
description: "JSON encoded list of charts to release"
|
|
required: true
|
|
type: string
|
|
default: "[]"
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "charts/**"
|
|
|
|
jobs:
|
|
prepare:
|
|
name: Prepare data required for workflow
|
|
runs-on: ubuntu-22.04
|
|
outputs:
|
|
libraryChartsToRelease: ${{ steps.filtered-charts.outputs.libraryChartsToRelease }}
|
|
otherChartsToRelease: ${{ steps.filtered-charts.outputs.otherChartsToRelease }}
|
|
steps:
|
|
# ----------------------------
|
|
# Setup
|
|
# ----------------------------
|
|
- name: Checkout
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Grab repository configuration
|
|
id: repo-config
|
|
shell: bash
|
|
run: |
|
|
echo "config=$(yq '.' '.ci/repo-config.yaml' -o json -I=0)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Get changed library charts
|
|
id: changed-library-charts
|
|
if: ${{ github.event_name != 'workflow_dispatch' }}
|
|
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
|
|
with:
|
|
matrix: true
|
|
path: charts
|
|
dir_names: true
|
|
dir_names_max_depth: 2
|
|
files: |
|
|
library/**
|
|
|
|
- name: Get changed charts
|
|
id: changed-charts
|
|
if: ${{ github.event_name != 'workflow_dispatch' }}
|
|
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
|
|
with:
|
|
matrix: true
|
|
path: charts
|
|
dir_names: true
|
|
dir_names_max_depth: 2
|
|
files_ignore: |
|
|
library/**
|
|
|
|
- name: Get specified charts
|
|
id: specified-charts
|
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
let input = '${{ inputs.charts }}';
|
|
let cwd = process.cwd();
|
|
|
|
let tmpCharts = []
|
|
if (input === '[]') {
|
|
console.log("Empty charts input, scanning for charts in repository");
|
|
const globber = await glob.create('charts/*/*', { implicitDescendants: false });
|
|
for await (const file of globber.globGenerator()) {
|
|
if (fs.lstatSync(file).isDirectory()) {
|
|
relativePath = file.slice(`${cwd}/charts/`.length);
|
|
tmpCharts.push(relativePath);
|
|
}
|
|
}
|
|
} else {
|
|
tmpCharts = JSON.parse(input);
|
|
tmpCharts.forEach(function (chart) {
|
|
const fullPath = `${cwd}/charts/${chart}`;
|
|
if (!fs.existsSync(fullPath)) {
|
|
core.setFailed(`Chart ${chart} does not exist in repository`);
|
|
process.exit(1);
|
|
}
|
|
if (!fs.lstatSync(fullPath).isDirectory()) {
|
|
core.setFailed(`${chart} is not a valid directory`);
|
|
process.exit(1);
|
|
}
|
|
});
|
|
}
|
|
|
|
let libraryCharts = tmpCharts.filter(chart => chart.startsWith('library/'));
|
|
core.setOutput('libraryChartsToRelease', JSON.stringify(libraryCharts));
|
|
let otherCharts = tmpCharts.filter(chart => !chart.startsWith('library/'));
|
|
core.setOutput('otherChartsToRelease', JSON.stringify(otherCharts));
|
|
|
|
- name: Filter out excluded charts
|
|
id: filtered-charts
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
let libraryChartsInput = ${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.libraryChartsToRelease || steps.changed-library-charts.outputs.all_changed_files }};
|
|
let otherChartsInput = ${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.otherChartsToRelease || steps.changed-charts.outputs.all_changed_files }};
|
|
let excludedFromRelease = ${{ steps.repo-config.outputs.config }}['excluded-charts-release'];
|
|
|
|
let libraryCharts = libraryChartsInput.filter(item => excludedFromRelease.indexOf(item) < 0);
|
|
core.setOutput('libraryChartsToRelease', JSON.stringify(libraryCharts));
|
|
let otherCharts = otherChartsInput.filter(item => excludedFromRelease.indexOf(item) < 0);
|
|
core.setOutput('otherChartsToRelease', JSON.stringify(otherCharts));
|
|
|
|
release-library-charts:
|
|
name: Release library charts
|
|
needs:
|
|
- prepare
|
|
if: ${{ needs.prepare.outputs.libraryChartsToRelease != '[]' && needs.prepare.outputs.libraryChartsToRelease != '' }}
|
|
strategy:
|
|
matrix:
|
|
chart: ${{ fromJSON(needs.prepare.outputs.libraryChartsToRelease) }}
|
|
fail-fast: false
|
|
max-parallel: 1
|
|
uses: ./.github/workflows/chart-release-steps.yaml
|
|
with:
|
|
chart: ${{ matrix.chart }}
|
|
createGithubRelease: true
|
|
publishToGhPages: true
|
|
publishToOciRegistry: false
|
|
deployGhPages: true
|
|
|
|
release-other-charts:
|
|
name: Release other charts
|
|
needs:
|
|
- prepare
|
|
- release-library-charts
|
|
if: |-
|
|
${{
|
|
!cancelled() &&
|
|
!contains(needs.*.result, 'failure') &&
|
|
(needs.prepare.outputs.otherChartsToRelease != '[]' && needs.prepare.outputs.otherChartsToRelease != '')
|
|
}}
|
|
strategy:
|
|
matrix:
|
|
chart: ${{ fromJSON(needs.prepare.outputs.otherChartsToRelease) }}
|
|
fail-fast: false
|
|
max-parallel: 1
|
|
uses: ./.github/workflows/chart-release-steps.yaml
|
|
with:
|
|
chart: ${{ matrix.chart }}
|
|
createGithubRelease: true
|
|
publishToGhPages: true
|
|
publishToOciRegistry: true
|
|
deployGhPages: true
|