Make action compatible with push events (#12)

This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-07-30 14:33:55 +02:00
parent d2d078c510
commit f1fcfe77d5
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
13 changed files with 179 additions and 75 deletions

View file

@ -6,9 +6,11 @@ on:
workflow_dispatch:
inputs:
chart:
description: "Chart to release"
default: "_all_"
required: true
description: >
Chart to release. Comma-separated string.
Defaults to releasing everything.
default: ""
required: false
push:
branches:
- main
@ -37,28 +39,13 @@ jobs:
path: "src"
fetch-depth: 0
- name: Collect changes
id: collect-changes
uses: ./src/.github/actions/collect-changes
- name: Collect charts to release
uses: ./src/.github/actions/collect-charts
id: collect-charts
with:
token: ${{ steps.get-app-token.outputs.token }}
working-directory: src
- name: Determine charts to release
id: charts-to-release
shell: bash
run: |
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.chartChangesDetected }}" == "true" ]; then
CHARTS=(${{ steps.collect-changes.outputs.addedOrModifiedCharts }})
fi
printf "::set-output name=charts::%s\n" "${CHARTS[*]}"
repoConfigFile: ./src/.ci/repo-config.yaml
overrideCharts: "[${{ inputs.chart }}]"
- name: Checkout gh-pages branch
uses: actions/checkout@v3
@ -80,9 +67,10 @@ jobs:
env:
SRC_DIR: "src/charts"
DEST_DIR: "dest"
CHARTS: "${{ steps.charts-to-release.outputs.charts }}"
run: |
for CHART in $CHARTS ; do
CHARTS=( $(yq --null-input e '${{ steps.collect-charts.outputs.charts }}[]' ) )
for CHART in "${CHARTS[@]}" ; do
mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n')
CHART_TYPE=${CHART_PATH_PARTS[0]}

View file

@ -54,7 +54,7 @@ jobs:
outputs:
addedOrModifiedFilesDetected: ${{ steps.changed-files.outputs.allAddedOrModified }}
addedOrModifiedFiles: ${{ steps.changed-files.outputs.allAddedOrModified_files }}
addedOrModifiedCharts: ${{ steps.changed-charts.outputs.changedCharts }}
addedOrModifiedCharts: ${{ steps.changed-charts.outputs.charts }}
chartsToLint: ${{ steps.changed-charts.outputs.chartsToLint }}
chartsToInstall: ${{ steps.changed-charts.outputs.chartsToInstall }}
steps:
@ -73,5 +73,5 @@ jobs:
- added|modified: '**'
- name: Collect changed charts
uses: ./.github/actions/collect-changed-charts
uses: ./.github/actions/collect-charts
id: changed-charts