kubezero/scripts/publish.sh

61 lines
1.3 KiB
Bash
Raw Normal View History

2020-05-01 15:33:41 +00:00
#!/bin/bash
2021-11-27 13:02:23 +00:00
set -ex
2023-08-16 10:17:39 +00:00
REPO_URL_S3="s3://zero-downtime-web-cdn/charts"
2021-11-27 13:02:23 +00:00
REPO_URL="https://cdn.zero-downtime.net/charts"
2020-05-01 15:33:41 +00:00
CHARTS=${1:-'.*'}
2020-05-01 15:33:41 +00:00
SRCROOT="$(cd "$(dirname "$0")/.." && pwd)"
2021-01-21 10:53:53 +00:00
TMPDIR=$(mktemp -d kubezero-repo.XXX)
2021-11-27 13:02:23 +00:00
mkdir -p $TMPDIR
2020-05-01 15:33:41 +00:00
2021-11-27 13:02:23 +00:00
[ -z "$DEBUG" ] && trap 'rm -rf $TMPDIR' ERR EXIT
2020-05-01 15:33:41 +00:00
2021-11-27 13:02:23 +00:00
function reset_index() {
aws s3 sync $REPO_URL_S3/ $TMPDIR/
helm repo index $TMPDIR --url $REPO_URL
aws s3 cp $TMPDIR/index.yaml $REPO_URL_S3/ --cache-control max-age=1
2022-10-27 12:27:42 +00:00
exit 0
}
2020-05-01 15:33:41 +00:00
function publish_chart() {
for dir in $(find -L $SRCROOT/charts -mindepth 1 -maxdepth 1 -type d);
do
name=$(basename $dir)
[[ $name =~ $CHARTS ]] || continue
2021-08-25 14:02:21 +00:00
#if [ $(helm dep list $dir 2>/dev/null| wc -l) -gt 1 ]
#then
# echo "Processing chart dependencies"
# rm -rf $dir/tmpcharts
# helm dependency update --skip-refresh $dir
#fi
2020-05-01 15:33:41 +00:00
echo "Processing $dir"
helm lint $dir
helm package -d $TMPDIR $dir
done
2021-01-21 10:53:53 +00:00
curl -L -s -o $TMPDIR/index.yaml ${REPO_URL}/index.yaml
helm repo index $TMPDIR --url $REPO_URL --merge $TMPDIR/index.yaml
for p in $TMPDIR/*.tgz; do
aws s3 cp $p $REPO_URL_S3/
done
aws s3 cp $TMPDIR/index.yaml $REPO_URL_S3/ --cache-control max-age=1
}
2022-10-27 12:27:42 +00:00
#reset_index
publish_chart
2023-08-16 10:17:39 +00:00
CF_DIST=E11OFTOA3L8IVY
aws cloudfront create-invalidation --distribution $CF_DIST --paths "/charts/*"