diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0de506c --- /dev/null +++ b/.github/workflows/main.yml @@ -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 "/*" diff --git a/src/utils/constants.js b/src/utils/constants.js index 31159dd..71fafa0 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -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;