Skip to content

Commit

Permalink
Merge pull request #816 from makerdao/develop
Browse files Browse the repository at this point in the history
To main
  • Loading branch information
eskp authored May 21, 2024
2 parents 4274284 + eabe962 commit 8da238d
Show file tree
Hide file tree
Showing 18 changed files with 657 additions and 189 deletions.
106 changes: 66 additions & 40 deletions .github/workflows/angular-dev.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,78 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Build DEV Angular
name: Build DEV Angular - Frontend

on:
push:
branches: [ develop ]
paths:
- "frontend/**"
# pull_request:
# branches: [ develop ]
# paths:
# - "frontend/**"
workflow_dispatch:
- ".github/workflows/angular-dev.yml"
- "helm/staging/frontend*"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
env:
REGION: us-east-2
CLUSTER_NAME: maker-staging
SERVICE_NAME: mips-frontend
AWS_ECR_NAME: mips-frontend-staging
ENVIRONMENT_TAG: staging
HELM_FILE: helm/staging/frontend.yaml

steps:
- uses: actions/checkout@v1

- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: npm install and npm run build
run: |
npm i
npm run build --prod
working-directory: frontend
- name: Copy file via scp
uses: appleboy/[email protected]
env:
HOST: ${{ secrets.SSH_HOST }}
USERNAME: ${{ secrets.SSH_USER }}
PORT: ${{ secrets.SSH_PORT }}
PASSWORD: ${{ secrets.SSH_PASS }}
with:
source: "./frontend/dist"
target: "/var/warehouse/makerdao-mips-develop"
- uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.REGION }}

- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Extract commit hash
id: vars
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }}
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build, tag, and push image to ECR
id: build-image
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }}
working-directory: frontend
env:
SHA_TAG: ${{ steps.vars.outputs.sha_short }}
LATEST_TAG: latest
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
# Build Docker containers and push them to ECR ${{ env.AWS_ECR_NAME }}
docker pull $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG || true
docker build -t $AWS_ECR_NAME \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$SHA_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$ENVIRONMENT_TAG \
--build-arg ENV=dev \
-f Dockerfile \
.
docker push $ECR_REGISTRY/$AWS_ECR_NAME --all-tags
- name: Deploying Service to Kubernetes with Helm
id: deploy
if: ${{ !contains(github.event.head_commit.message , '[skip deploy]') }}
uses: bitovi/[email protected]
with:
values: image.repository=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }},image.tag=${{ steps.vars.outputs.sha_short }}
cluster-name: ${{ env.CLUSTER_NAME }}
config-files: ${{ env.HELM_FILE }}
chart-path: techops-services/common
namespace: mips
timeout: 5m0s
name: ${{ env.SERVICE_NAME }}
chart-repository: https://techops-services.github.io/helm-charts
version: 0.0.31
atomic: true
107 changes: 67 additions & 40 deletions .github/workflows/angular-prod.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,78 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Build PROD Angular
name: Build Prod Angular - Frontend

on:
push:
branches: [ main ]
paths:
- "frontend/**"
# pull_request:
# branches: [ main ]
# paths:
# - "frontend/**"
- ".github/workflows/angular-prod.yml"
- "helm/prod/frontend*"

jobs:
deploy:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
env:
REGION: eu-central-1
CLUSTER_NAME: maker-prod-eu
SERVICE_NAME: mips-frontend
AWS_ECR_NAME: mips-frontend-prod
ENVIRONMENT_TAG: prod
HELM_FILE: helm/prod/frontend.yaml

steps:
- uses: actions/checkout@v3

- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: npm install and npm run build
run: |
npm i
npm run build-prod
working-directory: frontend
- name: Copy file via scp
uses: appleboy/[email protected]
env:
HOST: ${{ secrets.SSH_HOST }}
USERNAME: ${{ secrets.SSH_USER }}
PORT: ${{ secrets.SSH_PORT }}
PASSWORD: ${{ secrets.SSH_PASS }}
with:
source: "./frontend/dist"
target: "/var/warehouse/makerdao-mips"
- uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.REGION }}

- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Extract commit hash
id: vars
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }}
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build, tag, and push image to ECR
id: build-image
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }}
working-directory: frontend
env:
SHA_TAG: ${{ steps.vars.outputs.sha_short }}
LATEST_TAG: latest
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
# Build Docker containers and push them to ECR ${{ env.AWS_ECR_NAME }}
docker pull $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG || true
docker build -t $AWS_ECR_NAME \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$SHA_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$ENVIRONMENT_TAG \
--build-arg ENV=prod \
-f Dockerfile \
.
docker push $ECR_REGISTRY/$AWS_ECR_NAME --all-tags
- name: Deploying Service to Kubernetes with Helm
id: deploy
if: ${{ !contains(github.event.head_commit.message , '[skip deploy]') }}
uses: bitovi/[email protected]
with:
values: image.repository=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }},image.tag=${{ steps.vars.outputs.sha_short }}
cluster-name: ${{ env.CLUSTER_NAME }}
config-files: ${{ env.HELM_FILE }}
chart-path: techops-services/common
namespace: mips
timeout: 5m0s
name: ${{ env.SERVICE_NAME }}
chart-repository: https://techops-services.github.io/helm-charts
version: 0.0.31
atomic: true
117 changes: 69 additions & 48 deletions .github/workflows/node.js-dev.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,97 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js develop CI
name: Node.js develop CI - Backend

on:
push:
branches: [ develop ]
paths:
- "backend/**"
- ".github/workflows/node.js-dev.yml"
- "backend/**"
- ".github/workflows/node.js-dev.yml"
- "helm/staging/backend*"

jobs:
build:
build-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
env:
REGION: us-east-2
CLUSTER_NAME: maker-staging
SERVICE_NAME: mips-backend
AWS_ECR_NAME: mips-backend-staging
ENVIRONMENT_TAG: staging
HELM_FILE: helm/staging/backend.yaml

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Checkout
uses: actions/checkout@v4

- name: Running the Test Suit
env:
REQUEST_GITHUB_URL_API_ENDPOINT: ${{ secrets.REQUEST_GITHUB_URL_API_ENDPOINT }}
GIT_ACCESS_API_TOKEN: ${{ secrets.GIT_ACCESS_API_TOKEN }}
MIP_GITHUB_REPOSITORY: ${{ secrets.MIP_GITHUB_REPOSITORY_DEV }}
MIP_GITHUB_REPOSITORY_OWNER: ${{ secrets.MIP_GITHUB_REPOSITORY_OWNER_DEV }}
GIT_ACCESS_API_TOKEN: ${{ secrets.GIT_ACCESS_API_TOKEN }}
run: |
cp '.env example' .env
npm install
npm run pre-start-develop
npm test
working-directory: backend
working-directory: backend

deploy:
needs: [build]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Copy file via scp
uses: appleboy/scp-action@master
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
password: ${{ secrets.SSH_PASS }}
source: "./backend"
target: "/var/warehouse/makerdao-mips-develop"
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.REGION }}

- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Executing remote command
uses: appleboy/ssh-action@master
- name: Extract commit hash
id: vars
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }}
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build, tag, and push image to ECR
id: build-image
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }}
working-directory: backend
env:
SHA_TAG: ${{ steps.vars.outputs.sha_short }}
LATEST_TAG: latest
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REQUEST_GITHUB_URL_API_ENDPOINT: ${{ secrets.REQUEST_GITHUB_URL_API_ENDPOINT }}
GIT_ACCESS_API_TOKEN: ${{ secrets.GIT_ACCESS_API_TOKEN }}
MIP_GITHUB_REPOSITORY: ${{ secrets.MIP_GITHUB_REPOSITORY_DEV }}
MIP_GITHUB_REPOSITORY_OWNER: ${{ secrets.MIP_GITHUB_REPOSITORY_OWNER_DEV }}
GIT_ACCESS_API_TOKEN: ${{ secrets.GIT_ACCESS_API_TOKEN }}
run: |
# Build Docker containers and push them to ECR ${{ env.AWS_ECR_NAME }}
docker pull $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG || true
docker build -t $AWS_ECR_NAME \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$SHA_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$ENVIRONMENT_TAG \
--build-arg REQUEST_GITHUB_URL_API_ENDPOINT=$REQUEST_GITHUB_URL_API_ENDPOINT \
--build-arg GIT_ACCESS_API_TOKEN=$GIT_ACCESS_API_TOKEN \
-f Dockerfile \
.
docker push $ECR_REGISTRY/$AWS_ECR_NAME --all-tags
- name: Deploying Service to Kubernetes with Helm
id: deploy
if: ${{ !contains(github.event.head_commit.message , '[skip deploy]') }}
uses: bitovi/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
password: ${{ secrets.SSH_PASS }}
script: |
cd /var/warehouse/makerdao-mips-develop/backend
pm2 stop dist/main.js
npm install
npm run build
npm run pre-start-develop
npx nestjs-command drop:db
npx nestjs-command parse:mips
pm2 start dist/main.js --name "api-dev"
values: image.repository=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }},image.tag=${{ steps.vars.outputs.sha_short }}
cluster-name: ${{ env.CLUSTER_NAME }}
config-files: ${{ env.HELM_FILE }}
chart-path: techops-services/common
namespace: mips
timeout: 5m0s
name: ${{ env.SERVICE_NAME }}
chart-repository: https://techops-services.github.io/helm-charts
version: 0.0.31
atomic: true
Loading

0 comments on commit 8da238d

Please sign in to comment.