Merge pull request #1505 from culturecreates/enhancement/issue-1394 #792
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Staging build and deploy to S3 | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build-and-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.footlight.io | |
runs-on: ubuntu-latest | |
container: | |
image: sleavely/node-awscli:14.x | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: setup node | |
run: npm install | |
# Append additional environment variables to .env.staging | |
- name: Add extra env variables | |
run: | | |
echo "" >> .env.staging | |
echo "REACT_APP_GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" >> .env.staging | |
echo "REACT_APP_GOOGLE_MAPS_ID=${{ secrets.GOOGLE_MAPS_ID }}" >> .env.staging | |
- name: build | |
run: npm run build:staging | |
# Upload to S3 | |
- name: sync s3 | |
run: aws s3 sync ./build s3://${{env.WEBHOSTING_BUCKET_NAME}}/ --acl public-read --delete --exclude index.html | |
- name: set cache-control on index.html | |
run: aws s3 cp ./build/index.html s3://${{env.WEBHOSTING_BUCKET_NAME}}/index.html --metadata-directive REPLACE --cache-control max-age=0,s-maxage=86400 --acl public-read --content-type text/html | |
# Invalidate CloudFront | |
- name: Invalidate CloudFront | |
uses: chetan/invalidate-cloudfront-action@v2 | |
env: | |
DISTRIBUTION: E2R70C1WYD9KB | |
PATHS: "/*" |