Add changed_charts and chart_version outputs (#130)
* Add `changed_charts` and `chart_version` outputs This should let downstream steps make conditional decisions based on what we found. Also: fix a confusing double-negative test in main(). Signed-off-by: Nathan J. Mehl <n@oden.io> --------- Signed-off-by: Nathan J. Mehl <n@oden.io>
This commit is contained in:
@@ -21,6 +21,11 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi
|
||||
- `skip_packaging`: This option, when populated, will skip the packaging step. This allows you to do more advanced packaging of your charts (for example, with the `helm package` command) before this action runs. This action will only handle the indexing and publishing steps.
|
||||
- `mark_as_latest`: When you set this to `false`, it will mark the created GitHub release not as 'latest'.
|
||||
|
||||
### Outputs
|
||||
|
||||
- `changed_charts`: A comma-separated list of charts that were released on this run. Will be an empty string if no updates were detected, will be unset if `--skip_packaging` is used: in the latter case your custom packaging step is responsible for setting its own outputs if you need them.
|
||||
- `chart_version`: The version of the most recently generated charts; will be set even if no charts have been updated since the last run.
|
||||
|
||||
### Environment variables
|
||||
|
||||
- `CR_TOKEN` (required): The GitHub token of this repository (`${{ secrets.GITHUB_TOKEN }}`)
|
||||
|
||||
+17
-1
@@ -32,11 +32,19 @@ inputs:
|
||||
description: Mark the created GitHub release as 'latest'
|
||||
required: false
|
||||
default: true
|
||||
outputs:
|
||||
changed_charts:
|
||||
description: "A comma-separated list of charts that were released on this run. Will be an empty string if no updates were detected, will be unset if `--skip_packaging` is used: in the latter case your custom packaging step is responsible for setting its own outputs if you need them."
|
||||
value: ${{ steps.release.outputs.changed_charts }}
|
||||
chart_version:
|
||||
description: "The version of the most recently generated charts; will be set even if no charts have been updated since the last run."
|
||||
value: ${{ steps.release.outputs.chart_version }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- run: |
|
||||
- id: release
|
||||
run: |
|
||||
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
|
||||
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")
|
||||
|
||||
@@ -77,4 +85,12 @@ runs:
|
||||
fi
|
||||
|
||||
"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
|
||||
|
||||
if [[ -f changed_charts.txt ]]; then
|
||||
cat changed_charts.txt >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
if [[ -f chart_version.txt ]]; then
|
||||
cat chart_version.txt >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
rm -f changed_charts.txt chart_version.txt
|
||||
shell: bash
|
||||
|
||||
@@ -58,7 +58,7 @@ main() {
|
||||
repo_root=$(git rev-parse --show-toplevel)
|
||||
pushd "$repo_root" >/dev/null
|
||||
|
||||
if ! [[ -n "$skip_packaging" ]]; then
|
||||
if [[ -z "$skip_packaging" ]]; then
|
||||
echo 'Looking up latest tag...'
|
||||
local latest_tag
|
||||
latest_tag=$(lookup_latest_tag)
|
||||
@@ -80,14 +80,19 @@ main() {
|
||||
if [[ -d "$chart" ]]; then
|
||||
package_chart "$chart"
|
||||
else
|
||||
echo "Chart '$chart' no longer exists in repo. Skipping it..."
|
||||
echo "Nothing to do. No chart changes detected."
|
||||
fi
|
||||
done
|
||||
|
||||
release_charts
|
||||
update_index
|
||||
echo "changed_charts=$(
|
||||
IFS=,
|
||||
echo "${changed_charts[*]}"
|
||||
)" >changed_charts.txt
|
||||
else
|
||||
echo "Nothing to do. No chart changes detected."
|
||||
echo "changed_charts=" >changed_charts.txt
|
||||
fi
|
||||
else
|
||||
install_chart_releaser
|
||||
@@ -97,6 +102,8 @@ main() {
|
||||
update_index
|
||||
fi
|
||||
|
||||
echo "chart_version=${latest_tag}" >chart_version.txt
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user