diff --git a/.github/workflows/build-production-deploy-s3.yml b/.github/workflows/build-production-deploy-s3.yml index 28b43bb..ab8197d 100644 --- a/.github/workflows/build-production-deploy-s3.yml +++ b/.github/workflows/build-production-deploy-s3.yml @@ -17,4 +17,14 @@ jobs: - uses: actions/checkout@v2 - run: npm install - run: npm run build:production - - run: aws s3 sync ./build s3://${{env.WEBHOSTING_BUCKET_NAME}}/ --acl public-read --delete --cache-control max-age=3600 + - run: | + current_version=$(node -p "require('./package.json').version") + major_version=$(echo $current_version | cut -d. -f1) + + aws s3 sync ./build s3://${{env.WEBHOSTING_BUCKET_NAME}}/v${major_version}/ --acl public-read --cache-control max-age=3600 + + previous_major_version=$((major_version - 2)) + + if [ "$previous_major_version" -ge 0 ]; then + aws s3 rm s3://${{env.WEBHOSTING_BUCKET_NAME}}/v${previous_major_version}/ --recursive || true + fi