mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 00:27:04 +02:00
ci: More ci changes
This commit is contained in:
parent
c91cd7a050
commit
89be81f5b3
2 changed files with 101 additions and 14 deletions
54
.github/workflows/charts-release-steps.yaml
vendored
54
.github/workflows/charts-release-steps.yaml
vendored
|
@ -49,14 +49,6 @@ on:
|
|||
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
|
||||
|
@ -97,6 +89,7 @@ jobs:
|
|||
|
||||
- name: Grab chart details
|
||||
id: chart-details
|
||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
||||
shell: bash
|
||||
env:
|
||||
ROOT_DIR: charts
|
||||
|
@ -105,12 +98,57 @@ jobs:
|
|||
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"
|
||||
echo "changelog=$(yq '.annotations["artifacthub.io/changes"]' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml | yq -o=json -I=0 '.' | sed 's/\\n/ /g')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Format changelog
|
||||
id: changelog
|
||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
let input = '${{ steps.chart-details.outputs.changelog }}';
|
||||
let changelog = "## Changelog:";
|
||||
if (input === 'null') {
|
||||
changelog = changelog + "\nNo changelog provided.";
|
||||
} else {
|
||||
let inputParsed = JSON.parse(input);
|
||||
|
||||
var changelogGrouped = inputParsed.reduce((result, currentValue) => {
|
||||
(result[currentValue['kind']] = result[currentValue['kind']] || []).push(currentValue);
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
for (const key in changelogGrouped) {
|
||||
changelog = changelog + `\n### ${key[0].toUpperCase() + key.slice(1)}`;
|
||||
let entries = changelogGrouped[key];
|
||||
|
||||
entries.forEach(function (entry) {
|
||||
changelog = changelog + `\n- ${entry.description}`;
|
||||
if ('links' in entry) {
|
||||
entry.links.forEach(function (link) {
|
||||
changelog = changelog + `\n - [${link.name}](${link.url})`;
|
||||
});
|
||||
}
|
||||
});
|
||||
changelog = changelog + `\n`;
|
||||
}
|
||||
}
|
||||
console.log(changelog);
|
||||
core.setOutput('changelog', changelog);
|
||||
|
||||
- name: Create tag
|
||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
||||
uses: EndBug/latest-tag@latest
|
||||
with:
|
||||
ref: ${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}
|
||||
|
||||
- uses: ncipollo/release-action@v1
|
||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
||||
with:
|
||||
allowUpdates: true
|
||||
tag: ${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}
|
||||
body: ${{ steps.changelog.outputs.changelog }}
|
||||
|
||||
release-charts-to-github-pages:
|
||||
name: Release charts to GitHub Pages
|
||||
runs-on: ubuntu-22.04
|
||||
|
|
61
.github/workflows/charts-release.yaml
vendored
61
.github/workflows/charts-release.yaml
vendored
|
@ -5,6 +5,12 @@ concurrency: helm-release
|
|||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
charts:
|
||||
description: "JSON encoded list of charts to release"
|
||||
required: true
|
||||
type: string
|
||||
default: "[]"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
@ -17,8 +23,10 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
repoConfiguration: ${{ steps.repo-config.outputs.config }}
|
||||
libraryChartsToRelease: ${{ steps.changed-library-charts.outputs.all_changed_files }}
|
||||
otherChartsToRelease: ${{ steps.changed-charts.outputs.all_changed_files }}
|
||||
libraryChartsToRelease: |-
|
||||
${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.libraryChartsToRelease || steps.changed-library-charts.outputs.all_changed_files }}
|
||||
otherChartsToRelease: |-
|
||||
${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.otherChartsToRelease || steps.changed-charts.outputs.all_changed_files }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
@ -33,6 +41,7 @@ jobs:
|
|||
|
||||
- name: Get changed library charts
|
||||
id: changed-library-charts
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
uses: tj-actions/changed-files@v45
|
||||
with:
|
||||
matrix: true
|
||||
|
@ -44,6 +53,7 @@ jobs:
|
|||
|
||||
- name: Get changed charts
|
||||
id: changed-charts
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
uses: tj-actions/changed-files@v45
|
||||
with:
|
||||
matrix: true
|
||||
|
@ -53,11 +63,49 @@ jobs:
|
|||
files_ignore: |
|
||||
library/**
|
||||
|
||||
- name: Get specified charts
|
||||
id: specified-charts
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
let input = '${{ github.event.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()) {
|
||||
relativePath = file.slice(`${cwd}/charts/`.length);
|
||||
tmpCharts.push(relativePath);
|
||||
}
|
||||
} else {
|
||||
const fs = require('fs');
|
||||
tmpCharts = JSON.parse(input);
|
||||
tmpCharts.forEach(function (chart) {
|
||||
if (!fs.existsSync(`${cwd}/charts/${chart}`)) {
|
||||
core.setFailed(`Chart ${chart} does not exist in repository`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let libraryCharts = tmpCharts.filter(chart => chart.startsWith('library/'));
|
||||
let otherCharts = tmpCharts.filter(chart => !chart.startsWith('library/'));
|
||||
|
||||
console.log("Library charts:")
|
||||
console.log(JSON.stringify(libraryCharts));
|
||||
core.setOutput('libraryChartsToRelease', JSON.stringify(libraryCharts));
|
||||
console.log("Other charts:")
|
||||
console.log(JSON.stringify(otherCharts));
|
||||
core.setOutput('otherChartsToRelease', JSON.stringify(otherCharts));
|
||||
|
||||
release-library-charts:
|
||||
name: Release library charts
|
||||
needs:
|
||||
- prepare
|
||||
if: ${{ needs.prepare.outputs.libraryChartsToRelease != '[]' }}
|
||||
if: ${{ needs.prepare.outputs.libraryChartsToRelease != '[]' && needs.prepare.outputs.libraryChartsToRelease != '' }}
|
||||
uses: ./.github/workflows/charts-release-steps.yaml
|
||||
permissions:
|
||||
pages: write
|
||||
|
@ -75,10 +123,11 @@ jobs:
|
|||
needs:
|
||||
- prepare
|
||||
- release-library-charts
|
||||
if: |
|
||||
if: |-
|
||||
${{
|
||||
always() &&
|
||||
!failure() && !cancelled() &&
|
||||
!cancelled() &&
|
||||
(needs.prepare.result == 'skipped' || needs.prepare.result == 'success') &&
|
||||
(needs.release-library-charts.result == 'skipped' || needs.release-library-charts.result == 'success') &&
|
||||
needs.prepare.outputs.otherChartsToRelease != '[]'
|
||||
}}
|
||||
uses: ./.github/workflows/charts-release-steps.yaml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue