From 13b829b479f99770c5ce8004c5448be806196a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Wed, 27 Jul 2022 11:29:49 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=A7=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/collect-changes/action.yaml | 28 ++++++-- .github/workflows/charts-release.yaml | 78 +++++++++++---------- charts/stable/airsonic/Chart.yaml | 1 - charts/stable/alertmanager-bot/Chart.yaml | 1 - 4 files changed, 64 insertions(+), 44 deletions(-) diff --git a/.github/actions/collect-changes/action.yaml b/.github/actions/collect-changes/action.yaml index 3947f34a..eb42ef3a 100644 --- a/.github/actions/collect-changes/action.yaml +++ b/.github/actions/collect-changes/action.yaml @@ -1,6 +1,15 @@ name: "Collect changes" 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: changesDetected: description: "Whether or not changes to files have been detected" @@ -18,13 +27,12 @@ outputs: runs: using: "composite" steps: - - name: Set up chart-testing - uses: helm/chart-testing-action@v2.2.1 - - name: Collect changed files uses: dorny/paths-filter@v2 id: filter with: + token: ${{ inputs.token }} + working-directory: ${{ inputs.working-directory }} list-files: shell filters: | addedOrModified: @@ -36,6 +44,18 @@ runs: id: changed-charts shell: bash 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 printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}" diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 5905deae..80e29805 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -4,6 +4,11 @@ concurrency: helm-release on: workflow_dispatch: + inputs: + chart: + description: "Chart to release" + default: "_all_" + required: true push: branches: - main @@ -12,6 +17,7 @@ on: jobs: release-charts: + name: Release charts runs-on: ubuntu-22.04 steps: - name: Get k8s-at-home token @@ -29,33 +35,27 @@ jobs: fetch-depth: 0 - name: Collect changes - uses: dorny/paths-filter@v2 - id: filter + id: collect-changes + uses: ./src/.github/actions/collect-changes with: - list-files: shell + token: ${{ steps.get-app-token.outputs.token }} working-directory: src - filters: | - chartsAddedOrModified: - - added|modified: 'charts/*/**' - - name: Collect changed charts - if: | - steps.filter.outputs.chartsAddedOrModified == 'true' - id: filter-charts + - name: Determine charts to release + id: charts-to-release shell: bash run: | 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 - printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}" + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + if [ "${{ github.event.inputs.chart }}" == "_all_" ]; then + CHARTS=($(find "src/charts" -type f -name 'Chart.yaml' | sed -r 's|/[^/]+$||' | sed 's|src/charts/||' | sort | uniq)) + else + CHARTS=(${{ github.event.inputs.chart }}) + fi + elif [ "${{ steps.collect-changes.outputs.chartsAddedOrModified }}" == "true" ]; then + CHARTS=(${{ steps.collect-changes.outputs.addedOrModifiedCharts }}) + fi + printf "::set-output name=charts::%s\n" "${CHARTS[*]}" - name: Checkout gh-pages branch uses: actions/checkout@v3 @@ -67,35 +67,37 @@ jobs: - name: Install Helm uses: Azure/setup-helm@v3.3 + with: + token: ${{ steps.get-app-token.outputs.token }} - name: Package Helm Charts shell: bash env: SRC_DIR: "src/charts" DEST_DIR: "dest" - CHARTS: "${{ steps.filter-charts.outputs.addedOrModifiedCharts }}" + CHARTS: "${{ steps.charts-to-release.outputs.charts }}" run: | for CHART in $CHARTS ; do 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 package "${SRC_DIR}/${CHART}" -u -d "${DEST_DIR}/${CHART_TYPE}" done - # - name: Create new index - # shell: bash - # working-directory: dest - # run: | - # helm repo index . --url https://bjw-s.github.io/helm-charts/ + - name: Update chart index + shell: bash + working-directory: dest + run: | + helm repo index . --url https://bjw-s.github.io/helm-charts/ - # - name: Push changes - # shell: bash - # working-directory: dest - # run: | - # 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 add $(git ls-files -o --exclude-standard) - # git add index.yaml - # git commit -m "Updated from ref: $GITHUB_SHA" - # git push + - name: Commit changes + shell: bash + working-directory: dest + run: | + 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 add $(git ls-files -o --exclude-standard) + git add index.yaml + git commit -m "Updated from ref: $GITHUB_SHA" + git push diff --git a/charts/stable/airsonic/Chart.yaml b/charts/stable/airsonic/Chart.yaml index d812aafb..e5305b6b 100644 --- a/charts/stable/airsonic/Chart.yaml +++ b/charts/stable/airsonic/Chart.yaml @@ -7,7 +7,6 @@ version: 6.3.2 kubeVersion: ">=1.16.0-0" keywords: - airsonic - - trigger_ci 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 sources: diff --git a/charts/stable/alertmanager-bot/Chart.yaml b/charts/stable/alertmanager-bot/Chart.yaml index 8b7c7c69..5e851e5e 100644 --- a/charts/stable/alertmanager-bot/Chart.yaml +++ b/charts/stable/alertmanager-bot/Chart.yaml @@ -10,7 +10,6 @@ keywords: - telegram - bot - alerting - - trigger_ci 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 sources: