Skip to content

Commit

Permalink
Add github action to deploy to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
seadeep42 committed Aug 3, 2024
1 parent 4ba6dd4 commit dd0f2a9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
53 changes: 53 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Workflow for build and deploy of the BLR public transport webapp frontend to AWS
on:
push:
branches:
- main

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
deploy-prod:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v2

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Create env file
run: |
touch .env
echo "${{ secrets.BPT_FRONTEND_DOT_ENV }}" >> .env
- name: Install dependencies
run: yarn

- name: Build
run: yarn build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1

- name: Deploy dashboard to s3 bucket
run: aws s3 sync ./dist s3://${{ secrets.AWS_BPT_FRONTEND_BUCKET }}/

- name: Invalidate dashboard stage cloudfront
run: aws cloudfront create-invalidation --distribution-id AWS_BPT_CLOUDFRONT_DIST --paths "/*"
1 change: 0 additions & 1 deletion src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_TOKEN;
export const GOOGLE_API_KEY = import.meta.env.VITE_GOOGLE_API_KEY;
export const BACKEND_HOST = import.meta.env.VITE_PUBLIC_BACKEND_HOST;

export const MAX_HISTORY_LENGTH = 20;
Expand Down

0 comments on commit dd0f2a9

Please sign in to comment.