-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e029fb
commit 4b11616
Showing
1 changed file
with
76 additions
and
48 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 |
---|---|---|
@@ -1,70 +1,98 @@ | ||
name: S3 Deployment on the ALL-SAAS-DEV | ||
name: ALL SAAS LEARN FRIEND BUILD Deployment | ||
|
||
on: [push] | ||
on: | ||
push: | ||
branches: | ||
- release-0.3 | ||
|
||
jobs: | ||
build_and_deploy: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: all-saas-dev | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
node-version: '18' | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Clean up node_modules and package-lock.json | ||
run: | | ||
echo "Cleaning up node_modules and package-lock.json..." | ||
rm -rf node_modules | ||
rm -f package-lock.json | ||
- name: Install Dependencies | ||
run: npm install --legacy-peer-deps | ||
|
||
- name: Build Application | ||
run: | | ||
echo "Setting up environment variables and building the application..." | ||
if [ -f .env ]; then | ||
rm .env | ||
fi | ||
echo '${{ secrets.DEV_ENV }}' > .env | ||
npm run build | ||
- name: Run Husky Install | ||
run: npm run prepare | ||
|
||
- name: Show Current Directory | ||
run: | | ||
echo "Current Working Directory:" | ||
pwd | ||
- name: Build and Package Application | ||
env: | ||
SKIP_PREFLIGHT_CHECK: ${{ vars.SKIP_PREFLIGHT_CHECK }} | ||
REACT_APP_MODE: ${{ vars.REACT_APP_MODE }} | ||
REACT_APP_authToken: ${{ vars.REACT_APP_authToken }} | ||
REACT_APP_PID: ${{ vars.REACT_APP_PID }} | ||
REACT_APP_UID: ${{ vars.REACT_APP_UID }} | ||
REACT_APP_ID: ${{ vars.REACT_APP_ID }} | ||
REACT_APP_VER: ${{ vars.REACT_APP_VER }} | ||
REACT_APP_TIMEDIFF: ${{ vars.REACT_APP_TIMEDIFF }} | ||
REACT_APP_HOST: ${{ vars.REACT_APP_HOST }} | ||
REACT_APP_ENDPOINT: ${{ vars.REACT_APP_ENDPOINT }} | ||
REACT_APP_APISLUG: ${{ vars.REACT_APP_APISLUG }} | ||
REACT_APP_CHANNEL: ${{ vars.REACT_APP_CHANNEL }} | ||
REACT_APP_ENV: ${{ vars.REACT_APP_ENV }} | ||
REACT_APP_BATCHSIZE: ${{ vars.REACT_APP_BATCHSIZE }} | ||
REACT_APP_CONTENT_SIZE: ${{ vars.REACT_APP_CONTENT_SIZE }} | ||
REACT_APP_LANGUAGE: ${{ vars.REACT_APP_LANGUAGE }} | ||
REACT_APP_TELEMETRY_MODE: ${{ vars.REACT_APP_TELEMETRY_MODE }} | ||
REACT_APP_VIRTUAL_ID_HOST: ${{ vars.REACT_APP_VIRTUAL_ID_HOST }} | ||
REACT_APP_LEARNER_AI_ORCHESTRATION_HOST: ${{ vars.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST }} | ||
REACT_APP_LEARNER_AI_APP_HOST: ${{ vars.REACT_APP_LEARNER_AI_APP_HOST }} | ||
REACT_APP_CONTENT_SERVICE_APP_HOST: ${{ vars.REACT_APP_CONTENT_SERVICE_APP_HOST }} | ||
REACT_APP_CAPTURE_AUDIO: ${{ vars.REACT_APP_CAPTURE_AUDIO }} | ||
REACT_APP_AWS_S3_BUCKET_NAME: ${{ vars.REACT_APP_AWS_S3_BUCKET_NAME }} | ||
REACT_APP_AWS_S3_BUCKET_URL: ${{ vars.REACT_APP_AWS_S3_BUCKET_URL }} | ||
REACT_APP_AWS_S3_REGION: ${{ vars.REACT_APP_AWS_S3_REGION }} | ||
REACT_APP_AWS_S3_BUCKET_CONTENT_URL: ${{ vars.REACT_APP_AWS_S3_BUCKET_CONTENT_URL }} | ||
REACT_APP_MIN_DECIBELS: ${{ vars.REACT_APP_MIN_DECIBELS }} | ||
REACT_APP_IS_AUDIOPREPROCESSING: ${{ vars.REACT_APP_IS_AUDIOPREPROCESSING }} | ||
REACT_APP_POST_LEARNER_PROGRESS: ${{ vars.REACT_APP_POST_LEARNER_PROGRESS }} | ||
REACT_APP_IS_APP_IFRAME: ${{ vars.REACT_APP_IS_APP_IFRAME }} | ||
REACT_APP_IS_IN_APP_AUTHORISATION: ${{ vars.REACT_APP_IS_IN_APP_AUTHORISATION }} | ||
REACT_APP_LANGUAGES: ${{ vars.REACT_APP_LANGUAGES }} | ||
REACT_APP_AWS_ACCESS_KEY_ID: ${{ secrets.REACT_APP_AWS_ACCESS_KEY_ID }} | ||
REACT_APP_AWS_SECRET_ACCESS_KEY: ${{ secrets.REACT_APP_AWS_SECRET_ACCESS_KEY }} | ||
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }} | ||
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }} | ||
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }} | ||
CI: false # Disabling CI to not treat warnings as errors | ||
run: npm run build | ||
|
||
- name: List Directory Contents | ||
run: | | ||
echo "Contents of the current directory:" | ||
ls -lrta | ||
- name: Deploy to S3 Bucket | ||
run: aws s3 sync ./build s3://all-saas-learnerapp/learn-friend-build/ | ||
|
||
- name: List Dist Directory Contents | ||
- name: Debug Environment Variables | ||
run: | | ||
echo "Contents of the dist directory:" | ||
ls -lrta dist | ||
echo "REACT_APP_AWS_S3_BUCKET_NAME: $REACT_APP_AWS_S3_BUCKET_NAME" | ||
echo "AWS_REGION: $AWS_REGION" | ||
echo "secrate": ${{ vars.REACT_APP_AWS_S3_BUCKET_NAME }} | ||
- name: Install AWS CLI | ||
run: | | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get update | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y awscli | ||
- name: Configure AWS credentials | ||
run: | | ||
echo "Configuring AWS credentials..." | ||
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws configure set default.region ${{ secrets.AWS_S3_BUCKET_REGION }} | ||
- name: Upload to S3 Bucket | ||
run: | | ||
echo "Uploading contents of the dist directory to the S3 bucket..." | ||
aws s3 sync dist/ s3://${{ secrets.AWS_S3_BUCKET }}/ | ||
- name: Invalidate CloudFront Cache | ||
run: | | ||
echo "Invalidating CloudFront cache..." | ||
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" | ||
- name: Cloudfront Invalidation | ||
uses: chetan/invalidate-cloudfront-action@master | ||
env: | ||
DISTRIBUTION: ${{ secrets.AWS_DISTRIBUTION }} | ||
PATHS: "/*" | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |