Skip to content

Merge pull request #266 from undp/dependabot/npm_and_yarn/web/follow-… #26

Merge pull request #266 from undp/dependabot/npm_and_yarn/web/follow-…

Merge pull request #266 from undp/dependabot/npm_and_yarn/web/follow-… #26

name: Deploy Front end in S3
on:
push:
branches:
- main
paths:
- web/**
- .github/workflows/frontend*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy_front_end:
runs-on: ubuntu-latest
env:
REACT_APP_COUNTRY_NAME: "UNDP Digital Public Good National"
REACT_APP_COUNTRY_FLAG_URL: "https://carbon-common-prod.s3.amazonaws.com/flag.png"
COUNTRY_CODE: "NG"
REACT_APP_MAPBOXGL_ACCESS_TOKEN: ${{ secrets.MAPBOXGL_ACCESS_TOKEN }}
REACT_APP_MAP_TYPE: "Mapbox"
REACT_APP_GOVERNMENT_MINISTRY: "Ministry Of Environment"
steps:
- uses: actions/checkout@v3
- 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: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push the image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: carbon-web
IMAGE_TAG: main
run: |
# Build a docker container and push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=3030 --build-arg REACT_APP_BACKEND=http://localhost:3000 --build-arg REACT_APP_STAT_URL=http://localhost:3100 --build-arg REACT_APP_COUNTRY_NAME="UNDP Digital Public Good National" --build-arg COUNTRY_FLAG_URL="https://carbon-common-dev.s3.amazonaws.com/flag.png" --build-arg COUNTRY_CODE="NG" --build-arg REACT_APP_MAP_TYPE="Mapbox" --build-arg REACT_APP_MAPBOXGL_ACCESS_TOKEN=${{ secrets.MAPBOXGL_ACCESS_TOKEN }}
echo "Pushing image to ECR..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Deploy production frontend on Amazon EC2
env:
PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE_DEMO }}
HOSTNAME: ${{ secrets.HOST_IP_DEMO }}
USER_NAME: ec2-user
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '
repos/carbon-registry/frontend_deploy.sh '