Fix deploy

This commit is contained in:
Filippo Squillace 2020-12-30 00:13:58 +01:00
parent 2242585778
commit d3f9f13ccd
2 changed files with 6 additions and 5 deletions

View file

@ -87,4 +87,4 @@ after_success:
#######################
# Deploy and validation
#######################
- ./ci/deploy.sh ${PWD}/junest-x86_64.tar.gz
- ./ci/deploy.sh ./junest-x86_64.tar.gz

View file

@ -4,7 +4,7 @@ set -e
IMG_PATH=$1
set -u
set -ux
MAX_OLD_IMAGES=30
@ -31,14 +31,15 @@ then
# Upload image
# The put is done via a temporary filename in order to prevent outage on the
# production file for a longer period of time.
img_name=$(basename ${IMG_PATH})
cp ${IMG_PATH} ${IMG_PATH}.temp
aws s3 cp ${IMG_PATH}.temp s3://junest-repo/junest/
aws s3 mv s3://junest-repo/junest/${IMG_PATH}.temp s3://junest-repo/junest/${IMG_PATH}
aws s3api put-object-acl --acl public-read --bucket junest-repo --key junest/${IMG_PATH}
aws s3 mv s3://junest-repo/junest/$img_name.temp s3://junest-repo/junest/$img_name
aws s3api put-object-acl --acl public-read --bucket junest-repo --key junest/$img_name
DATE=$(date +'%Y-%m-%d-%H-%M-%S')
aws s3 cp ${IMG_PATH} s3://junest-repo/junest/${IMG_PATH}.${DATE}
aws s3 cp s3://junest-repo/junest/$img_name s3://junest-repo/junest/${img_name}.${DATE}
# Cleanup old images
aws s3 ls s3://junest-repo/junest/junest-${ARCH}.tar.gz. | awk '{print $4}' | head -n -${MAX_OLD_IMAGES} | xargs -I {} s3 rm "s3://junest-repo/junest/{}"