-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deploy workflow for staging and dev deployments
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Deploy Sdai-frontend UI to S3 Bucket | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- staging | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy to S3 Bucket | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Remove broken apt repos [Ubuntu] | ||
if: ${{ matrix.os }} == 'ubuntu-latest' | ||
run: | | ||
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.lock') }} | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.14.2 | ||
|
||
- name: Install | ||
run: | | ||
rm -rf .cache | ||
rm -rf build | ||
npm config set cache-folder .node | ||
npm install | ||
pip install awscli --upgrade --user | ||
- name: Build Release App | ||
if: ( github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' ) | ||
run: npm run build | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
if: ( github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/develop') | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | ||
|
||
|
||
# Script to deploy to dev environment | ||
- name: 'Deploy to S3: development' | ||
if: ( github.ref == 'refs/heads/develop' ) | ||
run: | | ||
aws s3 sync public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/development/ --delete --exclude "*.html" --cache-control max-age=86400,public | ||
aws s3 sync public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/development/ --delete --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html | ||
# Script to deploy to staging environment | ||
- name: 'Deploy to S3: staging' | ||
if: ( github.ref == 'refs/heads/staging' ) | ||
run: | | ||
aws s3 sync public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/staging/ --delete --exclude "*.html" --cache-control max-age=86400,public | ||
aws s3 sync public/ s3://${{ secrets.STAGING_BUCKET_NAME }}/staging/ --delete --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html |