Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prevent overriding releases. #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -63,3 +66,4 @@ runs:
- ${{ inputs.commit_email }}
- ${{ inputs.app_version }}
- ${{ inputs.chart_version }}
- ${{ inputs.override_releases }}
23 changes: 21 additions & 2 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down