Skip to content

chore: fixed production deployment script to handle versioning #98

chore: fixed production deployment script to handle versioning

chore: fixed production deployment script to handle versioning #98

name: Build and deploy develop branch to S3 Staging
on:
push:
branches:
- develop
jobs:
deploy:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
AWS_REGION: ca-central-1
WEBHOSTING_BUCKET_NAME: staging.cms-widget.footlight.io
runs-on: ubuntu-22.04
container:
image: sleavely/node-awscli:14.x
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm run build:staging
- 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