mongo #267
Workflow file for this run
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
# 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 - Backend | |
on: | |
push: | |
branches: [ docker ] | |
paths: | |
- "backend/**" | |
- ".github/workflows/node.js-dev.yml" | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
env: | |
REGION: us-east-2 | |
CLUSTER_NAME: maker-staging | |
SERVICE_NAME: mips-backend | |
AWS_ECR_NAME: mips-backend-staging | |
ENVIRONMENT_TAG: staging | |
HELM_FILE: backend/helm/staging/values.yaml | |
steps: | |
- 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 }} | |
run: | | |
cp '.env example' .env | |
npm install | |
npm run pre-start-develop | |
npm test | |
working-directory: backend | |
- 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: 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 }} | |
MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
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 \ | |
--build-arg MONGODB_URI=$MONGODB_URI \ | |
-f Dockerfile \ | |
. | |
docker push $ECR_REGISTRY/$AWS_ECR_NAME --all-tags | |
- name: Replace variables in the Helm values file | |
id: replace-vars | |
if: ${{ !contains(github.event.head_commit.message , '[skip deploy]') }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
# USERS_LIST: ${{ secrets.STAGING_USERS_LIST }} | |
run: | | |
sed -i 's/${ECR_REGISTRY}/'$ECR_REGISTRY/ $HELM_FILE | |
sed -i 's/${USERS_LIST}/'$USERS_LIST/ $HELM_FILE | |
- name: Deploying Service to Kubernetes with Helm | |
id: deploy | |
if: ${{ !contains(github.event.head_commit.message , '[skip deploy]') }} | |
uses: bitovi/github-actions-deploy-eks-helm@v1.2.8 | |
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: ${{ env.SERVICE_NAME }} | |
timeout: 5m0s | |
name: ${{ env.SERVICE_NAME }} | |
chart-repository: https://techops-services.github.io/helm-charts | |
version: 0.0.29 | |
atomic: true |