Skip to content

Commit

Permalink
Merge pull request #16 from xeptagondev/develop
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
mbelinsky authored Nov 1, 2023
2 parents 7710bb1 + cfc7f68 commit 56c3c86
Show file tree
Hide file tree
Showing 64 changed files with 1,601 additions and 1,466 deletions.
72 changes: 51 additions & 21 deletions .github/workflows/frontend-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ jobs:
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: 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
- name: Build
working-directory: ./web
run: CI=false yarn build
- name: Deploy
run: aws s3 sync ./web/build s3://mrv-www-dev
# - 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
# - name: Build
# working-directory: ./web
# run: CI=false yarn build
# - name: Deploy
# run: aws s3 sync ./web/build s3://mrv-www-dev
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
Expand All @@ -55,7 +55,37 @@ jobs:
IMAGE_TAG: v1
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=9030 --build-arg REACT_APP_BACKEND=http://18.234.193.80:9000 --build-arg REACT_APP_STAT_URL=http://18.234.193.80:9100 --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 }}
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=9030 --build-arg REACT_APP_BACKEND=https://transparency-demo.carbreg.org:9000 --build-arg REACT_APP_STAT_URL=https://transparency-demo.carbreg.org:9100 --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 }} --build-arg NGINX_CONFIG="nginx_prod.conf"
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 docker image to Amazon EC2
if: github.ref == 'refs/heads/develop'
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: transparency-web
IMAGE_TAG: v1
PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE }}
HOSTNAME: ${{secrets.HOST_IP}}
USER_NAME: ec2-user
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '
cd repos/carbon-transparency &&
sudo $(aws ecr get-login --no-include-email --region us-east-1) &&
sudo docker stop carbon-transparency-web-1 || true &&
sudo docker rm carbon-transparency-web-1 &&
sudo docker pull 302213478610.dkr.ecr.us-east-1.amazonaws.com/transparency-web:v1 &&
docker-compose -f docker-compose-image.yml up -d web '
- name: Build, tag, and push the QA-develop image to Amazon ECR
id: build-image-develop
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: transparency-web
IMAGE_TAG: develop
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:9000 --build-arg REACT_APP_STAT_URL=http://localhost:9100 --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"
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
55 changes: 27 additions & 28 deletions .github/workflows/server-deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ jobs:
# run: |
# cp -r node_modules ./dependency_layer
# ls
- name: serverless deploy develop
if: ${{ needs.check_dependency_change.outputs.deps_changed == 'True'}}
uses: serverless/[email protected]
with:
args: -c "cd ./backend/layer && serverless deploy --stage ${{ needs.check_dependency_change.outputs.stage }}"
entrypoint: /bin/sh
# - name: serverless deploy develop
# if: ${{ needs.check_dependency_change.outputs.deps_changed == 'True'}}
# uses: serverless/[email protected]
# with:
# args: -c "cd ./backend/layer && serverless deploy --stage ${{ needs.check_dependency_change.outputs.stage }}"
# entrypoint: /bin/sh
# - name: serverless deploy main
# if: ${{ needs.check_dependency_change.outputs.deps_changed == 'True' && github.ref == 'refs/heads/main'}}
# uses: serverless/[email protected]
Expand All @@ -85,24 +85,24 @@ jobs:
needs: [layer, check_dependency_change]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependency
working-directory: ./backend/services
run: yarn install --frozen-lockfile
- name: version
run: |
echo "ARN1=$(aws lambda list-layer-versions --layer-name service-dependencies-mrv-${{ needs.check_dependency_change.outputs.stage }}-1 --region us-east-1 --query 'LayerVersions[0].LayerVersionArn')" >> $GITHUB_OUTPUT
echo "ARN2=$(aws lambda list-layer-versions --layer-name service-dependencies-mrv-${{ needs.check_dependency_change.outputs.stage }}-2 --region us-east-1 --query 'LayerVersions[0].LayerVersionArn')" >> $GITHUB_OUTPUT
id: layerArn
- name: serverless deploy develop
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# - name: Install Dependency
# working-directory: ./backend/services
# run: yarn install --frozen-lockfile
# - name: version
# run: |
# echo "ARN1=$(aws lambda list-layer-versions --layer-name service-dependencies-mrv-${{ needs.check_dependency_change.outputs.stage }}-1 --region us-east-1 --query 'LayerVersions[0].LayerVersionArn')" >> $GITHUB_OUTPUT
# echo "ARN2=$(aws lambda list-layer-versions --layer-name service-dependencies-mrv-${{ needs.check_dependency_change.outputs.stage }}-2 --region us-east-1 --query 'LayerVersions[0].LayerVersionArn')" >> $GITHUB_OUTPUT
# id: layerArn
# - name: serverless deploy develop
# if: github.ref == 'refs/heads/develop'
uses: serverless/[email protected]
with:
args: -c "cd ./backend/services && serverless deploy --stage ${{ needs.check_dependency_change.outputs.stage }} --param='depLayerArn1=${{ steps.layerArn.outputs.ARN1 }}' --param='depLayerArn2=${{ steps.layerArn.outputs.ARN2 }}'"
entrypoint: /bin/sh
# uses: serverless/[email protected]
# with:
# args: -c "cd ./backend/services && serverless deploy --stage ${{ needs.check_dependency_change.outputs.stage }} --param='depLayerArn1=${{ steps.layerArn.outputs.ARN1 }}' --param='depLayerArn2=${{ steps.layerArn.outputs.ARN2 }}'"
# entrypoint: /bin/sh
# - name: serverless deploy main
# if: github.ref == 'refs/heads/main'
# uses: serverless/[email protected]
Expand Down Expand Up @@ -142,16 +142,15 @@ jobs:
PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE }}
HOSTNAME: ${{secrets.HOST_IP}}
USER_NAME: ec2-user

run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '
cd repos/carbon-transparency &&
sudo $(aws ecr get-login --no-include-email --region us-east-1) &&
sudo docker stop carbon-transparency-national-1 carbon-transparency-async-operations-handler-1 carbon-transparency-stats-1 || true &&
sudo docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG &&
docker compose -f docker-compose-image.yml up -d national stats async-operations-handler '
sudo docker rm carbon-transparency-national-1 carbon-transparency-async-operations-handler-1 carbon-transparency-stats-1 &&
sudo docker pull 302213478610.dkr.ecr.us-east-1.amazonaws.com/transparency-services:v1 &&
docker-compose -f docker-compose-image.yml up -d national stats async-operations-handler '
# automated-api-tests:
# runs-on: ubuntu-latest
Expand Down Expand Up @@ -191,4 +190,4 @@ jobs:





2 changes: 1 addition & 1 deletion .github/workflows/service-lib-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Update Version
working-directory: ./backend/services
run: yarn upgrade carbon-services-lib --latest
run: yarn upgrade @undp/carbon-services-lib --latest
- name: Commit Changes
working-directory: ./backend/services
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-service-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ on:
- '!main' # excludes master
paths:
- backend/**
- web/**
# - libs/**
- .github/workflows/server*
- .github/workflows/test-service*

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-web-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
- '!main' # excludes master
paths:
- web/**
- .github/workflows/frontend*
- backend/**
- .github/workflows/test-web*

jobs:
Test_web_build:
Expand Down Expand Up @@ -43,7 +44,7 @@ jobs:
IMAGE_TAG: ${{ github.head_ref || github.ref_name }}
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://18.234.193.80:3000 --build-arg REACT_APP_STAT_URL=http://18.234.193.80: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 }}
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=3030 --build-arg REACT_APP_BACKEND=http://localhost:9000 --build-arg REACT_APP_STAT_URL=http://localhost:9100 --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"
5 changes: 3 additions & 2 deletions backend/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@aws-sdk/client-qldb": "^3.433.0",
"@aws-sdk/node-http-handler": "^3.374.0",
"@aws-sdk/smithy-client": "^3.374.0",
"@casl/ability": "^6.3.2",
Expand All @@ -37,11 +38,12 @@
"@nestjs/swagger": "^6.1.3",
"@nestjs/typeorm": "^9.0.1",
"@undp/carbon-credit-calculator": "^1.0.0",
"@undp/carbon-services-lib": "0.0.236",
"@undp/serial-number-gen": "^1.0.0",
"aws-lambda": "^1.0.7",
"aws-serverless-express": "^3.4.0",
"axios": "^1.2.4",
"carbon-services-lib": "0.0.230",
"carbon-services-lib": "0.0.231-CARBON-276.0",
"cheerio": "^1.0.0-rc.12",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
Expand All @@ -65,7 +67,6 @@
"winston": "^3.8.2"
},
"devDependencies": {
"@aws-sdk/client-qldb": "^3.410.0",
"@aws-sdk/client-qldb-session": "^3.391.0",
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion backend/services/src/analytics-api/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Handler, Context } from "aws-lambda";
import { Server } from "http";
import { proxy } from "aws-serverless-express";
import { AnalyticsAPIModule, bootstrapServer } from "carbon-services-lib";
import { AnalyticsAPIModule, bootstrapServer } from "@undp/carbon-services-lib";

let cachedServer: Server;

Expand Down
6 changes: 3 additions & 3 deletions backend/services/src/async-operations-handler/handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NestFactory } from "@nestjs/core";
import { Handler, Context } from "aws-lambda";
import { getLogger } from "carbon-services-lib";
import { AsyncOperationsHandlerInterface } from "carbon-services-lib";
import { AsyncOperationsModuleMain } from "carbon-services-lib";
import { getLogger } from "@undp/carbon-services-lib";
import { AsyncOperationsHandlerInterface } from "@undp/carbon-services-lib";
import { AsyncOperationsModuleMain } from "@undp/carbon-services-lib";

export const handler: Handler = async (event: any, context: Context) => {
const app = await NestFactory.createApplicationContext(
Expand Down
6 changes: 3 additions & 3 deletions backend/services/src/data-importer/handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// lambda.ts
import { Handler, Context } from 'aws-lambda';
import { NestFactory } from '@nestjs/core';
import { getLogger } from 'carbon-services-lib';
import { DataImporterModule } from 'carbon-services-lib';
import { DataImporterService } from 'carbon-services-lib';
import { getLogger } from '@undp/carbon-services-lib';
import { DataImporterModule } from '@undp/carbon-services-lib';
import { DataImporterService } from '@undp/carbon-services-lib';

export const handler: Handler = async (event: any, context: Context) => {
const app = await NestFactory.createApplicationContext(DataImporterModule, {
Expand Down
4 changes: 2 additions & 2 deletions backend/services/src/i18n/en/creditCertification.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"certifyPendingProgramme": "The programme has been certified successfully",
"certifyPendingProgramme": "The project has been certified successfully",
"certifyRejectedProgramme": "This action is unauthorised",
"certifyProgrammeAlreadyCertifiedBySameCertifier": "This programme has already been certified",
"certifyProgrammeAlreadyCertifiedBySameCertifier": "This project has already been certified",
"unAuthorizedCertification": "This action is unauthorised",
"certificationRevocation": "The certificate has been revoked successfully"
}
Loading

0 comments on commit 56c3c86

Please sign in to comment.