Merge pull request #193 from undp/xeptagondev-unified #20
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
name: Deploy Front end in S3 | |
on: | |
push: | |
branches: | |
- unified | |
paths: | |
- web/** | |
- .github/workflows/frontend* | |
jobs: | |
deploy_front_end: | |
runs-on: ubuntu-latest | |
env: | |
REACT_APP_BACKEND: https://ck5kt5uaw1.execute-api.us-east-1.amazonaws.com/dev | |
COUNTRY_NAME: 'CountryX' | |
COUNTRY_FLAG_URL: 'https://carbon-common-dev.s3.amazonaws.com/flag.png' | |
COUNTRY_CODE: 'NG' | |
REACT_APP_MAPBOXGL_ACCESS_TOKEN: ${{ secrets.MAPBOXGL_ACCESS_TOKEN }} | |
REACT_APP_MAP_TYPE : "Mapbox" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache modules | |
uses: actions/cache@v1 | |
id: yarn-cache | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: ${{ runner.os }}-yarn- | |
- 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: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# - name: Install dependencies | |
# working-directory: ./web | |
# run: CI=false yarn install | |
# - name: Build | |
# working-directory: ./web | |
# run: CI=false yarn build | |
# - name: Deploy | |
# run: aws s3 sync ./web/build s3://carbon-www-dev | |
# - name: Deploy Test | |
# run: aws s3 sync ./web/build s3://www-test-carbon | |
- 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: unified | |
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://3.232.219.197:3000 --build-arg REACT_APP_STAT_URL=http://3.232.219.197:3100 --build-arg COUNTRY_NAME="CountryX" --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" |