diff --git a/action.yml b/action.yml index eac1ad5..41b9da2 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,9 @@ inputs: chart_version: description: "Set the version on the chart to this version" required: false + override_releases: + description: "If set to true will override already released chart versions" + required: false runs: using: 'docker' image: 'Dockerfile' @@ -63,3 +66,4 @@ runs: - ${{ inputs.commit_email }} - ${{ inputs.app_version }} - ${{ inputs.chart_version }} + - ${{ inputs.override_releases }} diff --git a/src/entrypoint.sh b/src/entrypoint.sh index cd79751..999c10b 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -30,6 +30,7 @@ COMMIT_USERNAME=${10} COMMIT_EMAIL=${11} APP_VERSION=${12} CHART_VERSION=${13} +OVERRIDE_RELEASES=${14} CHARTS=() CHARTS_TMP_DIR=$(mktemp -d) @@ -81,6 +82,10 @@ main() { COMMIT_EMAIL="${GITHUB_ACTOR}@users.noreply.github.com" fi + if [[ -z "$OVERRIDE_RELEASES" ]]; then + OVERRIDE_RELEASES="off" + fi + locate download dependencies @@ -150,7 +155,21 @@ upload() { charts=$(cd ${CHARTS_TMP_DIR} && ls *.tgz | xargs) mkdir -p ${TARGET_DIR} - mv -f ${CHARTS_TMP_DIR}/*.tgz ${TARGET_DIR} + + published=() + if [[ "$OVERRIDE_RELEASES" == "off" ]]; then + for chart in $charts; do + if ls "${TARGET_DIR}/${chart}" >& /dev/null; then + echo "Skipping already released chart ${chart}" + else + mv -v "${CHARTS_TMP_DIR}/${chart}" ${TARGET_DIR} + published+=(${chart}) + fi + done + else + mv -vf ${CHARTS_TMP_DIR}/*.tgz ${TARGET_DIR} + published=$charts + fi if [[ -f "${TARGET_DIR}/index.yaml" ]]; then echo "Found index, merging changes" @@ -161,7 +180,7 @@ upload() { fi git add ${TARGET_DIR} - git commit -m "Publish $charts" + git commit -m "Publish $published" git push origin ${BRANCH} popd >& /dev/null