This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-07-27 11:29:49 +02:00
parent 8da1255fad
commit 13b829b479
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
4 changed files with 64 additions and 44 deletions

View file

@ -1,6 +1,15 @@
name: "Collect changes" name: "Collect changes"
description: "Collects and stores changed files/charts" description: "Collects and stores changed files/charts"
inputs:
token:
required: true
description: "The Github API token to use"
working-directory:
required: false
description: "The working dir to use when checking for changes"
default: "."
outputs: outputs:
changesDetected: changesDetected:
description: "Whether or not changes to files have been detected" description: "Whether or not changes to files have been detected"
@ -18,13 +27,12 @@ outputs:
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.2.1
- name: Collect changed files - name: Collect changed files
uses: dorny/paths-filter@v2 uses: dorny/paths-filter@v2
id: filter id: filter
with: with:
token: ${{ inputs.token }}
working-directory: ${{ inputs.working-directory }}
list-files: shell list-files: shell
filters: | filters: |
addedOrModified: addedOrModified:
@ -36,6 +44,18 @@ runs:
id: changed-charts id: changed-charts
shell: bash shell: bash
run: | run: |
CHARTS=$(ct list-changed --config .ci/ct/ct-lint.yaml) CHARTS=()
PATHS=(${{ steps.filter.outputs.chartsAddedOrModified_files }})
# Get only the chart paths
for CHARTPATH in "${PATHS[@]}"
do
IFS='/' read -r -a path_parts <<< "${CHARTPATH}"
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
done
# Remove duplicates
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` )
# Set output to changed charts # Set output to changed charts
printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}" printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}"

View file

@ -4,6 +4,11 @@ concurrency: helm-release
on: on:
workflow_dispatch: workflow_dispatch:
inputs:
chart:
description: "Chart to release"
default: "_all_"
required: true
push: push:
branches: branches:
- main - main
@ -12,6 +17,7 @@ on:
jobs: jobs:
release-charts: release-charts:
name: Release charts
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- name: Get k8s-at-home token - name: Get k8s-at-home token
@ -29,33 +35,27 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Collect changes - name: Collect changes
uses: dorny/paths-filter@v2 id: collect-changes
id: filter uses: ./src/.github/actions/collect-changes
with: with:
list-files: shell token: ${{ steps.get-app-token.outputs.token }}
working-directory: src working-directory: src
filters: |
chartsAddedOrModified:
- added|modified: 'charts/*/**'
- name: Collect changed charts - name: Determine charts to release
if: | id: charts-to-release
steps.filter.outputs.chartsAddedOrModified == 'true'
id: filter-charts
shell: bash shell: bash
run: | run: |
CHARTS=() CHARTS=()
PATHS=(${{ steps.filter.outputs.chartsAddedOrModified_files }}) if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
# Get only the chart paths if [ "${{ github.event.inputs.chart }}" == "_all_" ]; then
for CHARTPATH in "${PATHS[@]}" CHARTS=($(find "src/charts" -type f -name 'Chart.yaml' | sed -r 's|/[^/]+$||' | sed 's|src/charts/||' | sort | uniq))
do else
IFS='/' read -r -a path_parts <<< "${CHARTPATH}" CHARTS=(${{ github.event.inputs.chart }})
CHARTS+=("${path_parts[1]}/${path_parts[2]}") fi
done elif [ "${{ steps.collect-changes.outputs.chartsAddedOrModified }}" == "true" ]; then
# Remove duplicates CHARTS=(${{ steps.collect-changes.outputs.addedOrModifiedCharts }})
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` ) fi
# Set output to changed charts printf "::set-output name=charts::%s\n" "${CHARTS[*]}"
printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}"
- name: Checkout gh-pages branch - name: Checkout gh-pages branch
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -67,35 +67,37 @@ jobs:
- name: Install Helm - name: Install Helm
uses: Azure/setup-helm@v3.3 uses: Azure/setup-helm@v3.3
with:
token: ${{ steps.get-app-token.outputs.token }}
- name: Package Helm Charts - name: Package Helm Charts
shell: bash shell: bash
env: env:
SRC_DIR: "src/charts" SRC_DIR: "src/charts"
DEST_DIR: "dest" DEST_DIR: "dest"
CHARTS: "${{ steps.filter-charts.outputs.addedOrModifiedCharts }}" CHARTS: "${{ steps.charts-to-release.outputs.charts }}"
run: | run: |
for CHART in $CHARTS ; do for CHART in $CHARTS ; do
mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n') mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n')
CHART_TYPE=${CHART_PATH_PARTS[2]} CHART_TYPE=${CHART_PATH_PARTS[0]}
helm dep up "${SRC_DIR}/${CHART}" helm dep up "${SRC_DIR}/${CHART}"
helm package "${SRC_DIR}/${CHART}" -u -d "${DEST_DIR}/${CHART_TYPE}" helm package "${SRC_DIR}/${CHART}" -u -d "${DEST_DIR}/${CHART_TYPE}"
done done
# - name: Create new index - name: Update chart index
# shell: bash shell: bash
# working-directory: dest working-directory: dest
# run: | run: |
# helm repo index . --url https://bjw-s.github.io/helm-charts/ helm repo index . --url https://bjw-s.github.io/helm-charts/
# - name: Push changes - name: Commit changes
# shell: bash shell: bash
# working-directory: dest working-directory: dest
# run: | run: |
# git config user.name "bjw-s-bot[bot]" git config user.name "bjw-s-bot[bot]"
# git config user.email "bjw-s-bot <87358111+bjw-s-bot[bot]@users.noreply.github.com>" git config user.email "bjw-s-bot <87358111+bjw-s-bot[bot]@users.noreply.github.com>"
# git add $(git ls-files -o --exclude-standard) git add $(git ls-files -o --exclude-standard)
# git add index.yaml git add index.yaml
# git commit -m "Updated from ref: $GITHUB_SHA" git commit -m "Updated from ref: $GITHUB_SHA"
# git push git push

View file

@ -7,7 +7,6 @@ version: 6.3.2
kubeVersion: ">=1.16.0-0" kubeVersion: ">=1.16.0-0"
keywords: keywords:
- airsonic - airsonic
- trigger_ci
home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/airsonic home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/airsonic
icon: https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/airsonic-logo.png icon: https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/airsonic-logo.png
sources: sources:

View file

@ -10,7 +10,6 @@ keywords:
- telegram - telegram
- bot - bot
- alerting - alerting
- trigger_ci
home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/alertmanager-bot home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/alertmanager-bot
icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png
sources: sources: