From fd4d0c34363c8f8536a3b3381cd829797ad61e89 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 16:18:57 +0530 Subject: [PATCH 01/40] feat(ci): add GitHub Actions workflow for deploying to Novu Cloud --- .github/workflows/deploy.yml | 181 +++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000000..a3a5d6392b0 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,181 @@ +name: Deploy to Novu Cloud +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy to' + required: true + type: choice + options: + - development + - production-us + - production-eu + - production-both + + deploy_api: + description: 'Deploy API?' + required: true + type: boolean + default: true + deploy_worker: + description: 'Deploy Worker?' + required: true + type: boolean + default: false + deploy_ws: + description: 'Deploy WS?' + required: true + type: boolean + default: false + deploy_webhook: + description: 'Deploy Webhook?' + required: true + type: boolean + default: false + +jobs: + prepare-matrix: + runs-on: ubuntu-latest + outputs: + env_matrix: ${{ steps.set-matrix.outputs.env_matrix }} + service_matrix: ${{ steps.set-matrix.outputs.service_matrix }} + steps: + - name: Generate Environment & Service Matrices + id: set-matrix + run: | + envs=() + services=() + + # Collect selected environments + if [ "${{ github.event.inputs.environment }}" == "development" ]; then + envs+=("\"development\"") + fi + if [ "${{ github.event.inputs.environment }}" == "production-us" ]; then + envs+=("\"production-us\"") + fi + if [ "${{ github.event.inputs.environment }}" == "production-eu" ]; then + envs+=("\"production-eu\"") + fi + if [ "${{ github.event.inputs.environment }}" == "production-both" ]; then + envs+=("\"production-us\"") + envs+=("\"production-eu\"") + fi + + # Collect selected services + if [ "${{ github.event.inputs.deploy_api }}" == "true" ]; then + services+=("\"api\"") + fi + if [ "${{ github.event.inputs.deploy_worker }}" == "true" ]; then + services+=("\"worker\"") + fi + if [ "${{ github.event.inputs.deploy_ws }}" == "true" ]; then + services+=("\"ws\"") + fi + if [ "${{ github.event.inputs.deploy_webhook }}" == "true" ]; then + services+=("\"webhook\"") + fi + + env_matrix="{\"environment\": [$( + IFS=','; echo "${envs[*]}" + )]}" + service_matrix="{\"service\": [$( + IFS=','; echo "${services[*]}" + )]}" + + echo "env_matrix=$env_matrix" >> $GITHUB_OUTPUT + echo "service_matrix=$service_matrix" >> $GITHUB_OUTPUT + + build: + needs: prepare-matrix + timeout-minutes: 60 + runs-on: ubuntu-latest + outputs: + docker_image: ${{ steps.build-image.outputs.IMAGE }} + strategy: + matrix: + service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + token: ${{ secrets.SUBMODULES_TOKEN }} + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.11.0 + run_install: false + + - name: Setup Node Version + uses: actions/setup-node@v4 + with: + node-version: '20.8.1' + cache: 'pnpm' + + - name: Install Dependencies + shell: bash + run: pnpm install --frozen-lockfile + + - name: Set Up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: 'image=moby/buildkit:v0.13.1' + + - name: Prepare Variables + run: | + set -e + if [[ "$(echo ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }})" == "development" ]]; then + echo "AWS_REGION=eu-west-2" >> $GITHUB_ENV + else + echo "AWS_REGION=us-east-1" >> $GITHUB_ENV + fi + echo "BULL_MQ_PRO_NPM_TOKEN=${{ secrets.BULL_MQ_PRO_NPM_TOKEN }}" >> $GITHUB_ENV + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID}} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: novu/${{ matrix.service }} + SERVICE: ${{ matrix.service }} + IMAGE_TAG: ${{ github.sha }} + DOCKER_BUILD_ARGUMENTS: > + --platform=linux/amd64 + --output=type=image,name=$REGISTRY/$REPOSITORY,push-by-digest=true,name-canonical=true + run: | + cp scripts/dotenvcreate.mjs apps/$SERVICE/src/dotenvcreate.mjs + cd apps/$SERVICE && pnpm --silent --workspace-root pnpm-context -- apps/$SERVICE/Dockerfile | BULL_MQ_PRO_NPM_TOKEN=${BULL_MQ_PRO_NPM_TOKEN} docker buildx build --secret id=BULL_MQ_PRO_NPM_TOKEN --build-arg PACKAGE_PATH=apps/$SERVICE - -t novu-$SERVICE --load $DOCKER_BUILD_ARGUMENTS + docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:latest + docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:prod + docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:$IMAGE_TAG + + docker push $REGISTRY/$REPOSITORY:prod + docker push $REGISTRY/$REPOSITORY:latest + docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG + echo "IMAGE=$REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + deploy: + needs: [build, prepare-matrix] + runs-on: ubuntu-latest + strategy: + matrix: + env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} + service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} + steps: + - name: Print Important Info + run: | + echo "Deploying ${{ matrix.service }} to ${{ matrix.env }}" + echo "Docker Image: ${{ needs.build.outputs.docker_image }}" From 013da7da516dd4bbb165810235cbd32311fdc805 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 16:22:00 +0530 Subject: [PATCH 02/40] feat(ci): set default deployment environment to development --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a3a5d6392b0..1f03d13d6e5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,6 +6,7 @@ on: description: 'Environment to deploy to' required: true type: choice + default: development options: - development - production-us From bb6cba51b9b69ac15d7a884e591a44629b679e99 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 20:13:01 +0530 Subject: [PATCH 03/40] fix(deploy): standardize environment naming to 'Development' --- .github/workflows/deploy.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1f03d13d6e5..26f868b4fcd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,9 +6,9 @@ on: description: 'Environment to deploy to' required: true type: choice - default: development + default: Development options: - - development + - Development - production-us - production-eu - production-both @@ -48,8 +48,8 @@ jobs: services=() # Collect selected environments - if [ "${{ github.event.inputs.environment }}" == "development" ]; then - envs+=("\"development\"") + if [ "${{ github.event.inputs.environment }}" == "Development" ]; then + envs+=("\"Development\"") fi if [ "${{ github.event.inputs.environment }}" == "production-us" ]; then envs+=("\"production-us\"") @@ -90,6 +90,7 @@ jobs: needs: prepare-matrix timeout-minutes: 60 runs-on: ubuntu-latest + environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} outputs: docker_image: ${{ steps.build-image.outputs.IMAGE }} strategy: @@ -128,7 +129,7 @@ jobs: - name: Prepare Variables run: | set -e - if [[ "$(echo ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }})" == "development" ]]; then + if [[ "$(echo ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }})" == "Development" ]]; then echo "AWS_REGION=eu-west-2" >> $GITHUB_ENV else echo "AWS_REGION=us-east-1" >> $GITHUB_ENV @@ -137,6 +138,8 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 + env: + AWS_REGION: ${{ env.AWS_REGION }} with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID}} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 53b8b338e69b84fc00f30df5495e305597ee1f60 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 20:14:09 +0530 Subject: [PATCH 04/40] fix(deploy): update environment variable extraction in workflow --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 26f868b4fcd..419d2208985 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -90,7 +90,7 @@ jobs: needs: prepare-matrix timeout-minutes: 60 runs-on: ubuntu-latest - environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} + environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} outputs: docker_image: ${{ steps.build-image.outputs.IMAGE }} strategy: From 09ab87ae7f632c92f7a24c1ed7ad477676755346 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 20:36:29 +0530 Subject: [PATCH 05/40] fix(deploy): streamline AWS region configuration and remove redundant Docker tags --- .github/workflows/deploy.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 419d2208985..8961fe40059 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -127,23 +127,14 @@ jobs: driver-opts: 'image=moby/buildkit:v0.13.1' - name: Prepare Variables - run: | - set -e - if [[ "$(echo ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }})" == "Development" ]]; then - echo "AWS_REGION=eu-west-2" >> $GITHUB_ENV - else - echo "AWS_REGION=us-east-1" >> $GITHUB_ENV - fi - echo "BULL_MQ_PRO_NPM_TOKEN=${{ secrets.BULL_MQ_PRO_NPM_TOKEN }}" >> $GITHUB_ENV + run: echo "BULL_MQ_PRO_NPM_TOKEN=${{ secrets.BULL_MQ_PRO_NPM_TOKEN }}" >> $GITHUB_ENV - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 - env: - AWS_REGION: ${{ env.AWS_REGION }} with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID}} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} + aws-region: ${{ secrets.AWS_REGION }} - name: Login to Amazon ECR id: login-ecr @@ -163,10 +154,7 @@ jobs: cp scripts/dotenvcreate.mjs apps/$SERVICE/src/dotenvcreate.mjs cd apps/$SERVICE && pnpm --silent --workspace-root pnpm-context -- apps/$SERVICE/Dockerfile | BULL_MQ_PRO_NPM_TOKEN=${BULL_MQ_PRO_NPM_TOKEN} docker buildx build --secret id=BULL_MQ_PRO_NPM_TOKEN --build-arg PACKAGE_PATH=apps/$SERVICE - -t novu-$SERVICE --load $DOCKER_BUILD_ARGUMENTS docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:latest - docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:prod docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:$IMAGE_TAG - - docker push $REGISTRY/$REPOSITORY:prod docker push $REGISTRY/$REPOSITORY:latest docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG echo "IMAGE=$REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT From 30558ec9397f14ff585738b97765bc00615a8cf0 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 20:36:34 +0530 Subject: [PATCH 06/40] fix(api): update Dockerfile to use base image from GitHub Container Registry --- apps/api/Dockerfile | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 6d51faf0d53..ba458fc9f6d 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -1,17 +1,4 @@ -FROM node:20-alpine3.19 AS dev_base -RUN apk add g++ make py3-pip - -ENV NX_DAEMON=false - -RUN npm i pm2 -g -RUN npm --no-update-notifier --no-fund --global install pnpm@9.11.0 -RUN pnpm --version - -USER 1000 -WORKDIR /usr/src/app - -# ------- DEV BUILD ---------- -FROM dev_base AS dev +FROM ghcr.io/novuhq/novu/base:1.0.0 AS dev ARG PACKAGE_PATH COPY --chown=1000:1000 ./meta . From 09772effd83c8b30bcf6c23a1c27919744d91c0e Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 20:40:31 +0530 Subject: [PATCH 07/40] fix(api): update Dockerfile to use specific base image from GitHub Container Registry --- apps/api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index ba458fc9f6d..2f20ef878cc 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -35,7 +35,7 @@ WORKDIR /usr/src/app RUN rm -rf node_modules && pnpm recursive exec -- rm -rf ./src ./node_modules # ------- PRODUCTION BUILD ---------- -FROM dev_base AS prod +FROM ghcr.io/novuhq/novu/base:1.0.0 AS prod ARG PACKAGE_PATH From 73126583f9c7ba43cd59123c3f3a81dc16e64321 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 1 Apr 2025 21:00:49 +0530 Subject: [PATCH 08/40] fix(deploy): update repository path in workflow to use secret for ECR repository prefix --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8961fe40059..8b934fd9584 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -144,7 +144,7 @@ jobs: id: build-image env: REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REPOSITORY: novu/${{ matrix.service }} + REPOSITORY: ${{ secrets.ECR_REPO_PREFIX }}/${{ matrix.service }} SERVICE: ${{ matrix.service }} IMAGE_TAG: ${{ github.sha }} DOCKER_BUILD_ARGUMENTS: > From f6ed3b5a1d02c0e3fda497d2885475a9f2a69bff Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Wed, 2 Apr 2025 13:32:11 +0530 Subject: [PATCH 09/40] fix(deploy): update workflow descriptions for clarity and consistency --- .github/workflows/deploy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8b934fd9584..ea1392ecabe 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,22 +14,22 @@ on: - production-both deploy_api: - description: 'Deploy API?' + description: 'Deploy API' required: true type: boolean default: true deploy_worker: - description: 'Deploy Worker?' + description: 'Deploy Worker' required: true type: boolean default: false deploy_ws: - description: 'Deploy WS?' + description: 'Deploy WS' required: true type: boolean default: false deploy_webhook: - description: 'Deploy Webhook?' + description: 'Deploy Webhook' required: true type: boolean default: false From 4cd2a7704fc9a7dd1fbdb72a0716725ac1b54f15 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Wed, 2 Apr 2025 13:32:27 +0530 Subject: [PATCH 10/40] fix(worker): update Dockerfile to use specific base image for development and production builds --- apps/worker/Dockerfile | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/apps/worker/Dockerfile b/apps/worker/Dockerfile index ee0043a2aa6..c863efc083f 100644 --- a/apps/worker/Dockerfile +++ b/apps/worker/Dockerfile @@ -1,16 +1,5 @@ -FROM node:20-alpine3.19 AS dev_base -RUN apk --update --no-cache add curl g++ make py3-pip -ENV NX_DAEMON=false - -RUN npm i pm2 -g -RUN npm --no-update-notifier --no-fund --global install pnpm@9.11.0 -RUN pnpm --version - -USER 1000 -WORKDIR /usr/src/app - # ------- DEV BUILD ---------- -FROM dev_base AS dev +FROM ghcr.io/novuhq/novu/base:1.0.0 AS dev ARG PACKAGE_PATH COPY --chown=1000:1000 ./meta . @@ -48,7 +37,7 @@ WORKDIR /usr/src/app RUN rm -rf node_modules && pnpm recursive exec -- rm -rf ./src ./node_modules # ------- PRODUCTION BUILD ---------- -FROM dev_base AS prod +FROM ghcr.io/novuhq/novu/base:1.0.0 AS prod ARG PACKAGE_PATH ENV CI=true From 5c67d85597463996a3e081e347310c610ae6e133 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Wed, 2 Apr 2025 15:47:21 +0530 Subject: [PATCH 11/40] fix(deploy): simplify Docker build command in deployment workflow --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ea1392ecabe..99c686af9b6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -152,7 +152,7 @@ jobs: --output=type=image,name=$REGISTRY/$REPOSITORY,push-by-digest=true,name-canonical=true run: | cp scripts/dotenvcreate.mjs apps/$SERVICE/src/dotenvcreate.mjs - cd apps/$SERVICE && pnpm --silent --workspace-root pnpm-context -- apps/$SERVICE/Dockerfile | BULL_MQ_PRO_NPM_TOKEN=${BULL_MQ_PRO_NPM_TOKEN} docker buildx build --secret id=BULL_MQ_PRO_NPM_TOKEN --build-arg PACKAGE_PATH=apps/$SERVICE - -t novu-$SERVICE --load $DOCKER_BUILD_ARGUMENTS + cd apps/$SERVICE && pnpm run docker:build docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:latest docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:$IMAGE_TAG docker push $REGISTRY/$REPOSITORY:latest From 8e3b1fa8aade60cd0515b3b955a528e6a8c9d7b3 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Wed, 2 Apr 2025 16:01:50 +0530 Subject: [PATCH 12/40] fix(ws): remove unnecessary package copies from Dockerfile --- apps/ws/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/ws/Dockerfile b/apps/ws/Dockerfile index 67a018e8878..9cd6b2586aa 100644 --- a/apps/ws/Dockerfile +++ b/apps/ws/Dockerfile @@ -21,8 +21,6 @@ COPY --chown=1000:1000 libs/testing ./libs/testing COPY --chown=1000:1000 libs/application-generic ./libs/application-generic COPY --chown=1000:1000 packages/client ./packages/client COPY --chown=1000:1000 packages/stateless ./packages/stateless -COPY --chown=1000:1000 packages/node ./packages/node -COPY --chown=1000:1000 packages/framework ./packages/framework COPY --chown=1000:1000 packages/providers ./packages/providers COPY --chown=1000:1000 ["tsconfig.json","nx.json","pnpm-workspace.yaml","pnpm-lock.yaml", ".npmrc", "./"] From a945909fa7ee00083364a03cfb3098cafa633e28 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Wed, 2 Apr 2025 16:10:19 +0530 Subject: [PATCH 13/40] fix(ws): add framework package copy to Dockerfile --- apps/ws/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/ws/Dockerfile b/apps/ws/Dockerfile index 9cd6b2586aa..8fabd1367f6 100644 --- a/apps/ws/Dockerfile +++ b/apps/ws/Dockerfile @@ -20,6 +20,7 @@ COPY --chown=1000:1000 packages/shared ./packages/shared COPY --chown=1000:1000 libs/testing ./libs/testing COPY --chown=1000:1000 libs/application-generic ./libs/application-generic COPY --chown=1000:1000 packages/client ./packages/client +COPY --chown=1000:1000 packages/framework ./packages/framework COPY --chown=1000:1000 packages/stateless ./packages/stateless COPY --chown=1000:1000 packages/providers ./packages/providers From a94073a1a0de68e296261ba744c691d08748c890 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Wed, 2 Apr 2025 16:12:51 +0530 Subject: [PATCH 14/40] fix(ws): update Dockerfile to use a new base image and streamline setup --- apps/ws/Dockerfile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/apps/ws/Dockerfile b/apps/ws/Dockerfile index 8fabd1367f6..84f0af42323 100644 --- a/apps/ws/Dockerfile +++ b/apps/ws/Dockerfile @@ -1,13 +1,4 @@ -FROM node:20-alpine3.19 - -ENV NX_DAEMON=false - -RUN npm install -g pnpm@9.11.0 --loglevel notice -RUN npm i pm2 -g -RUN apk --no-cache add g++ make py3-pip - -USER 1000 -WORKDIR /usr/src/app +FROM ghcr.io/novuhq/novu/base:1.0.0 COPY --chown=1000:1000 .npmrc . COPY --chown=1000:1000 .npmrc-cloud . From 0f6de8dbc8f03ff2ae44691ca7df67f3a3c3ed1b Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 00:40:28 +0530 Subject: [PATCH 15/40] fix(deploy): update default environment to staging and adjust environment variables --- .github/workflows/deploy.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 99c686af9b6..dd485976eb7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,9 +6,9 @@ on: description: 'Environment to deploy to' required: true type: choice - default: Development + default: staging options: - - Development + - staging - production-us - production-eu - production-both @@ -48,18 +48,18 @@ jobs: services=() # Collect selected environments - if [ "${{ github.event.inputs.environment }}" == "Development" ]; then - envs+=("\"Development\"") + if [ "${{ github.event.inputs.environment }}" == "staging" ]; then + envs+=("\"staging-eu\"") fi if [ "${{ github.event.inputs.environment }}" == "production-us" ]; then - envs+=("\"production-us\"") + envs+=("\"prod-us\"") fi if [ "${{ github.event.inputs.environment }}" == "production-eu" ]; then - envs+=("\"production-eu\"") + envs+=("\"prod-eu\"") fi if [ "${{ github.event.inputs.environment }}" == "production-both" ]; then - envs+=("\"production-us\"") - envs+=("\"production-eu\"") + envs+=("\"prod-us\"") + envs+=("\"prod-eu\"") fi # Collect selected services @@ -134,7 +134,7 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID}} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.AWS_REGION }} + aws-region: ${{ vars.AWS_REGION }} - name: Login to Amazon ECR id: login-ecr @@ -144,7 +144,7 @@ jobs: id: build-image env: REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REPOSITORY: ${{ secrets.ECR_REPO_PREFIX }}/${{ matrix.service }} + REPOSITORY: ${{ vars.ECR_REPO_PREFIX }}/${{ matrix.service }} SERVICE: ${{ matrix.service }} IMAGE_TAG: ${{ github.sha }} DOCKER_BUILD_ARGUMENTS: > From e4cc2c7876298d854f8e6825ac60b4c9aa273ede Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 01:40:05 +0530 Subject: [PATCH 16/40] fix(deploy): enhance deployment matrix generation and update service handling --- .github/workflows/deploy.yml | 76 +++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dd485976eb7..c8c3979bc2d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,25 +40,29 @@ jobs: outputs: env_matrix: ${{ steps.set-matrix.outputs.env_matrix }} service_matrix: ${{ steps.set-matrix.outputs.service_matrix }} + deploy_matrix: ${{ steps.set-matrix.outputs.deploy_matrix }} steps: - - name: Generate Environment & Service Matrices + - name: Generate Environment, Service, and Deploy Matrices id: set-matrix + env: + WORKER_SERVICE: ${{ secrets.WORKER_SERVICE }} run: | envs=() services=() + deploy_matrix=() # Collect selected environments if [ "${{ github.event.inputs.environment }}" == "staging" ]; then envs+=("\"staging-eu\"") fi if [ "${{ github.event.inputs.environment }}" == "production-us" ]; then - envs+=("\"prod-us\"") + envs+=("\"prod\"") fi if [ "${{ github.event.inputs.environment }}" == "production-eu" ]; then envs+=("\"prod-eu\"") fi if [ "${{ github.event.inputs.environment }}" == "production-both" ]; then - envs+=("\"prod-us\"") + envs+=("\"prod\"") envs+=("\"prod-eu\"") fi @@ -76,15 +80,51 @@ jobs: services+=("\"webhook\"") fi + # Parse service secrets and generate deploy_matrix + for service in "${services[@]}"; do + if [ "$service" == "\"worker\"" ]; then + IFS=',' read -r -a worker_services <<< "$WORKER_SERVICE" + for worker_service in "${worker_services[@]}"; do + cluster_name=$(echo "$worker_service" | jq -r '.cluster_name') + container_name=$(echo "$worker_service" | jq -r '.container_name') + service_name=$(echo "$worker_service" | jq -r '.service') + task_name=$(echo "$worker_service" | jq -r '.task_name') + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + done + elif [ "$service" == "\"api\"" ]; then + cluster_name=api-cluster + container_name=api-container + service_name=api-service + task_name=api-task + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + elif [ "$service" == "\"ws\"" ]; then + cluster_name=ws-cluster + container_name=ws-container + service_name=ws-service + task_name=ws-task + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + elif [ "$service" == "\"webhook\"" ]; then + cluster_name=webhook-cluster + container_name=webhook-container + service_name=webhook-service + task_name=webhook-task + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + fi + done + env_matrix="{\"environment\": [$( IFS=','; echo "${envs[*]}" )]}" service_matrix="{\"service\": [$( IFS=','; echo "${services[*]}" )]}" + deploy_matrix="[$( + IFS=','; echo "${deploy_matrix[*]}" + )]" echo "env_matrix=$env_matrix" >> $GITHUB_OUTPUT echo "service_matrix=$service_matrix" >> $GITHUB_OUTPUT + echo "deploy_matrix=$deploy_matrix" >> $GITHUB_OUTPUT build: needs: prepare-matrix @@ -92,7 +132,7 @@ jobs: runs-on: ubuntu-latest environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} outputs: - docker_image: ${{ steps.build-image.outputs.IMAGE }} + registry: ${{ steps.build-image.outputs.registry }} strategy: matrix: service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} @@ -144,20 +184,20 @@ jobs: id: build-image env: REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REPOSITORY: ${{ vars.ECR_REPO_PREFIX }}/${{ matrix.service }} + REPOSITORY: ${{ vars.ECR_REPO_PREFIX }} SERVICE: ${{ matrix.service }} IMAGE_TAG: ${{ github.sha }} DOCKER_BUILD_ARGUMENTS: > --platform=linux/amd64 - --output=type=image,name=$REGISTRY/$REPOSITORY,push-by-digest=true,name-canonical=true + --output=type=image,name=$REGISTRY/$REPOSITORY/$SERVICE,push-by-digest=true,name-canonical=true run: | cp scripts/dotenvcreate.mjs apps/$SERVICE/src/dotenvcreate.mjs cd apps/$SERVICE && pnpm run docker:build - docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:latest - docker tag novu-$SERVICE $REGISTRY/$REPOSITORY:$IMAGE_TAG - docker push $REGISTRY/$REPOSITORY:latest - docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG - echo "IMAGE=$REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + docker tag novu-$SERVICE $REGISTRY/$REPOSITORY/$SERVICE:latest + docker tag novu-$SERVICE $REGISTRY/$REPOSITORY/$SERVICE:$IMAGE_TAG + docker push $REGISTRY/$REPOSITORY/$SERVICE:latest + docker push $REGISTRY/$REPOSITORY/$SERVICE:$IMAGE_TAG + echo "registry=$REGISTRY/$REPOSITORY" >> $GITHUB_OUTPUT deploy: needs: [build, prepare-matrix] @@ -165,9 +205,17 @@ jobs: strategy: matrix: env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} - service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} + service: ${{ fromJson(needs.prepare-matrix.outputs.deploy_matrix) }} steps: - name: Print Important Info + env: + IMAGE_TAG: ${{ github.sha }} + REGISTRY: ${{ needs.build.outputs.registry }} run: | - echo "Deploying ${{ matrix.service }} to ${{ matrix.env }}" - echo "Docker Image: ${{ needs.build.outputs.docker_image }}" + echo "Deploying to cluster: ${{matrix.env}}-${{ matrix.service.cluster_name }}" + echo "Deploying to service: ${{matrix.env}}-${{ matrix.service.service_name }}" + echo "Deploying to container: ${{ matrix.service.container_name }}" + echo "Deploying to task: ${{ matrix.service.task_name }}" + + echo "Deploying to environment: ${{ matrix.env }}" + echo "Deploying to image: $REGISTRY/$IMAGE_TAG" From f0245f2533dacdb7452bfdb97cf92cea25ee7a11 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 01:59:03 +0530 Subject: [PATCH 17/40] fix(deploy): update WORKER_SERVICE reference from secrets to vars in deployment matrix --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c8c3979bc2d..7516da82475 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -45,7 +45,7 @@ jobs: - name: Generate Environment, Service, and Deploy Matrices id: set-matrix env: - WORKER_SERVICE: ${{ secrets.WORKER_SERVICE }} + WORKER_SERVICE: ${{ vars.WORKER_SERVICE }} run: | envs=() services=() From 942348e198b895cee2eebb4df378110891660a00 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 02:01:48 +0530 Subject: [PATCH 18/40] fix(deploy): clean up whitespace and enhance environment variable handling in deployment workflow --- .github/workflows/deploy.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7516da82475..2cb4c976155 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -136,7 +136,7 @@ jobs: strategy: matrix: service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} - + steps: - name: Checkout uses: actions/checkout@v4 @@ -165,7 +165,7 @@ jobs: uses: docker/setup-buildx-action@v3 with: driver-opts: 'image=moby/buildkit:v0.13.1' - + - name: Prepare Variables run: echo "BULL_MQ_PRO_NPM_TOKEN=${{ secrets.BULL_MQ_PRO_NPM_TOKEN }}" >> $GITHUB_ENV @@ -175,7 +175,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID}} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ vars.AWS_REGION }} - + - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v2 @@ -206,16 +206,18 @@ jobs: matrix: env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} service: ${{ fromJson(needs.prepare-matrix.outputs.deploy_matrix) }} + + environment: ${{ matrix.env }} steps: - name: Print Important Info env: IMAGE_TAG: ${{ github.sha }} REGISTRY: ${{ needs.build.outputs.registry }} + AWS_REGION: ${{ vars.AWS_REGION }} run: | echo "Deploying to cluster: ${{matrix.env}}-${{ matrix.service.cluster_name }}" echo "Deploying to service: ${{matrix.env}}-${{ matrix.service.service_name }}" echo "Deploying to container: ${{ matrix.service.container_name }}" echo "Deploying to task: ${{ matrix.service.task_name }}" - + echo "Deploying to region: ${AWS_REGION}" echo "Deploying to environment: ${{ matrix.env }}" - echo "Deploying to image: $REGISTRY/$IMAGE_TAG" From 1791af6171b47d9653ed484d624f3ec6d856afab Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 02:05:37 +0530 Subject: [PATCH 19/40] fix(deploy): update deploy matrix to correctly handle worker service properties --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2cb4c976155..b23b68382d0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -84,12 +84,12 @@ jobs: for service in "${services[@]}"; do if [ "$service" == "\"worker\"" ]; then IFS=',' read -r -a worker_services <<< "$WORKER_SERVICE" - for worker_service in "${worker_services[@]}"; do + for worker_service in $(echo "$WORKER_SERVICE" | jq -c '.[]'); do cluster_name=$(echo "$worker_service" | jq -r '.cluster_name') container_name=$(echo "$worker_service" | jq -r '.container_name') service_name=$(echo "$worker_service" | jq -r '.service') task_name=$(echo "$worker_service" | jq -r '.task_name') - deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service\": \"$service_name\", \"task_name\": \"$task_name\"}") done elif [ "$service" == "\"api\"" ]; then cluster_name=api-cluster From f3c7f6a3b196b3a84524d90c7e9948a9e482edc5 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 13:57:01 +0530 Subject: [PATCH 20/40] fix(deploy): update environment variables for production deployment and adjust repository prefix --- .github/workflows/deploy.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b23b68382d0..219d8c1b107 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,13 +56,13 @@ jobs: envs+=("\"staging-eu\"") fi if [ "${{ github.event.inputs.environment }}" == "production-us" ]; then - envs+=("\"prod\"") + envs+=("\"prod-us\"") fi if [ "${{ github.event.inputs.environment }}" == "production-eu" ]; then envs+=("\"prod-eu\"") fi if [ "${{ github.event.inputs.environment }}" == "production-both" ]; then - envs+=("\"prod\"") + envs+=("\"prod-us\"") envs+=("\"prod-eu\"") fi @@ -184,7 +184,7 @@ jobs: id: build-image env: REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REPOSITORY: ${{ vars.ECR_REPO_PREFIX }} + REPOSITORY: ${{ vars.ECR_PREFIX }} SERVICE: ${{ matrix.service }} IMAGE_TAG: ${{ github.sha }} DOCKER_BUILD_ARGUMENTS: > @@ -214,10 +214,10 @@ jobs: IMAGE_TAG: ${{ github.sha }} REGISTRY: ${{ needs.build.outputs.registry }} AWS_REGION: ${{ vars.AWS_REGION }} + ECS_PREFIX: ${{ vars.ECS_PREFIX }} run: | - echo "Deploying to cluster: ${{matrix.env}}-${{ matrix.service.cluster_name }}" - echo "Deploying to service: ${{matrix.env}}-${{ matrix.service.service_name }}" - echo "Deploying to container: ${{ matrix.service.container_name }}" - echo "Deploying to task: ${{ matrix.service.task_name }}" + echo "Deploying to cluster: ${ECS_PREFIX}-${{ matrix.service.cluster_name }}" + echo "Deploying to service: ${ECS_PREFIX}-${{ matrix.service.service_name }}" + echo "Deploying to container: ${ECS_PREFIX}-${{ matrix.service.container_name }}" + echo "Deploying to task: ${ECS_PREFIX}-${{ matrix.service.task_name }}" echo "Deploying to region: ${AWS_REGION}" - echo "Deploying to environment: ${{ matrix.env }}" From 1f6fce9f45b83cef889aa4435f2620caa8f36e21 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 14:15:49 +0530 Subject: [PATCH 21/40] fix(deploy): correct key name in deploy matrix for worker service --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 219d8c1b107..f77b836b5ae 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -89,7 +89,7 @@ jobs: container_name=$(echo "$worker_service" | jq -r '.container_name') service_name=$(echo "$worker_service" | jq -r '.service') task_name=$(echo "$worker_service" | jq -r '.task_name') - deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service\": \"$service_name\", \"task_name\": \"$task_name\"}") + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") done elif [ "$service" == "\"api\"" ]; then cluster_name=api-cluster From 71740493abf89477bfaeec2737dcdd3c0d1483df Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 14:47:34 +0530 Subject: [PATCH 22/40] fix(deploy): enhance deploy matrix to include image details and update ECS deployment steps --- .github/workflows/deploy.yml | 48 ++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f77b836b5ae..40be79df59a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -89,26 +89,30 @@ jobs: container_name=$(echo "$worker_service" | jq -r '.container_name') service_name=$(echo "$worker_service" | jq -r '.service') task_name=$(echo "$worker_service" | jq -r '.task_name') - deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + image=$(echo "$worker_service" | jq -r '.image') + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") done elif [ "$service" == "\"api\"" ]; then cluster_name=api-cluster container_name=api-container service_name=api-service task_name=api-task - deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + image=api + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") elif [ "$service" == "\"ws\"" ]; then cluster_name=ws-cluster container_name=ws-container service_name=ws-service task_name=ws-task - deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + image=ws + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") elif [ "$service" == "\"webhook\"" ]; then cluster_name=webhook-cluster container_name=webhook-container service_name=webhook-service task_name=webhook-task - deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\"}") + image=webhook + deploy_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") fi done @@ -209,15 +213,33 @@ jobs: environment: ${{ matrix.env }} steps: - - name: Print Important Info + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.AWS_REGION }} + + - name: Download task definition env: - IMAGE_TAG: ${{ github.sha }} - REGISTRY: ${{ needs.build.outputs.registry }} - AWS_REGION: ${{ vars.AWS_REGION }} ECS_PREFIX: ${{ vars.ECS_PREFIX }} + TASK_NAME: ${{ matrix.service.task_name }} run: | - echo "Deploying to cluster: ${ECS_PREFIX}-${{ matrix.service.cluster_name }}" - echo "Deploying to service: ${ECS_PREFIX}-${{ matrix.service.service_name }}" - echo "Deploying to container: ${ECS_PREFIX}-${{ matrix.service.container_name }}" - echo "Deploying to task: ${ECS_PREFIX}-${{ matrix.service.task_name }}" - echo "Deploying to region: ${AWS_REGION}" + aws ecs describe-task-definition --task-definition ${ECS_PREFIX}-${TASK_NAME} \ + --query taskDefinition > task-definition.json + + - name: Render Amazon ECS task definition + id: render-web-container + uses: aws-actions/amazon-ecs-render-task-definition@39c13cf530718ffeb524ec8ee0c15882bcb13842 + with: + task-definition: task-definition.json + container-name: ${{ vars.ECS_PREFIX }}-${{ matrix.service.container_name }} + image: ${{secrets.ECR_URI}}/${{ vars.ECR_PREFIX }}/${{ matrix.service.image }}:${{ github.sha }} + + - name: Deploy to Amazon ECS service + uses: aws-actions/amazon-ecs-deploy-task-definition@3e7310352de91b71a906e60c22af629577546002 + with: + task-definition: ${{ steps.render-web-container.outputs.task-definition }} + service: ${{ vars.ECS_PREFIX }}-${{ matrix.service.service_name }} + cluster: ${{ vars.ECS_PREFIX }}-${{ matrix.service.cluster_name }} + wait-for-service-stability: true From 95c455166e3e0f3be2f74995fafe14a860a483e9 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Tue, 8 Apr 2025 16:22:57 +0530 Subject: [PATCH 23/40] fix(docker): update base image for dev and prod stages to use dev_base --- apps/worker/Dockerfile | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/worker/Dockerfile b/apps/worker/Dockerfile index c863efc083f..13d1b3b294b 100644 --- a/apps/worker/Dockerfile +++ b/apps/worker/Dockerfile @@ -1,5 +1,18 @@ +FROM node:20-alpine3.19 AS dev_base +RUN apk --update --no-cache add curl g++ make py3-pip +ENV NX_DAEMON=false + + +RUN npm i pm2 -g +RUN npm --no-update-notifier --no-fund --global install pnpm@9.11.0 +RUN pnpm --version + + +USER 1000 +WORKDIR /usr/src/app + # ------- DEV BUILD ---------- -FROM ghcr.io/novuhq/novu/base:1.0.0 AS dev +FROM dev_base AS dev ARG PACKAGE_PATH COPY --chown=1000:1000 ./meta . @@ -37,7 +50,7 @@ WORKDIR /usr/src/app RUN rm -rf node_modules && pnpm recursive exec -- rm -rf ./src ./node_modules # ------- PRODUCTION BUILD ---------- -FROM ghcr.io/novuhq/novu/base:1.0.0 AS prod +FROM dev_base AS prod ARG PACKAGE_PATH ENV CI=true From ea051f9bc3fb2288dc9f9015df36352a5592671d Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 13:09:39 +0530 Subject: [PATCH 24/40] feat(deploy): add New Relic and Sentry release steps to deployment workflow --- .github/workflows/deploy.yml | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 40be79df59a..cbee884a8db 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -41,6 +41,7 @@ jobs: env_matrix: ${{ steps.set-matrix.outputs.env_matrix }} service_matrix: ${{ steps.set-matrix.outputs.service_matrix }} deploy_matrix: ${{ steps.set-matrix.outputs.deploy_matrix }} + nr_matrix: ${{ steps.set-matrix.outputs.nr_matrix }} steps: - name: Generate Environment, Service, and Deploy Matrices id: set-matrix @@ -69,9 +70,11 @@ jobs: # Collect selected services if [ "${{ github.event.inputs.deploy_api }}" == "true" ]; then services+=("\"api\"") + nr+=("\"api\"") fi if [ "${{ github.event.inputs.deploy_worker }}" == "true" ]; then services+=("\"worker\"") + nr+=("\"worker\"") fi if [ "${{ github.event.inputs.deploy_ws }}" == "true" ]; then services+=("\"ws\"") @@ -125,10 +128,14 @@ jobs: deploy_matrix="[$( IFS=','; echo "${deploy_matrix[*]}" )]" + nr_matrix="[$( + IFS=','; echo "${nr[*]}" + )]" echo "env_matrix=$env_matrix" >> $GITHUB_OUTPUT echo "service_matrix=$service_matrix" >> $GITHUB_OUTPUT echo "deploy_matrix=$deploy_matrix" >> $GITHUB_OUTPUT + echo "nr_matrix=$nr_matrix" >> $GITHUB_OUTPUT build: needs: prepare-matrix @@ -212,6 +219,7 @@ jobs: service: ${{ fromJson(needs.prepare-matrix.outputs.deploy_matrix) }} environment: ${{ matrix.env }} + steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 @@ -243,3 +251,57 @@ jobs: service: ${{ vars.ECS_PREFIX }}-${{ matrix.service.service_name }} cluster: ${{ vars.ECS_PREFIX }}-${{ matrix.service.cluster_name }} wait-for-service-stability: true + + + sentry_release: + needs: [deploy, prepare-matrix] + runs-on: ubuntu-latest + strategy: + matrix: + env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} + service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} + + environment: ${{ matrix.env }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get NPM Version + id: package-version + uses: martinbeentjes/npm-get-version-action@main + with: + path: apps/${{ matrix.service }} + + - name: Create Sentry release + uses: getsentry/action-release@v1 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ vars.SENTRY_ORG }} + SENTRY_PROJECT: ${{ matrix.service }} + with: + version: ${{ steps.package-version.outputs.current-version}} + version_prefix: v + environment: ${{vars.SENTRY_ENV}} + ignore_empty: true + ignore_missing: true + + new_relic_release: + needs: [deploy, prepare-matrix] + runs-on: ubuntu-latest + strategy: + matrix: + env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} + nr: ${{ fromJson(needs.prepare-matrix.outputs.nr_matrix) }} + environment: ${{ matrix.env }} + + steps: + - name: New Relic Application Deployment Marker + uses: newrelic/deployment-marker-action@v2.3.0 + with: + region: EU + apiKey: ${{ secrets.NEW_RELIC_API_KEY }} + guid: ${{ matrix.nr == 'api' && secrets.NEW_RELIC_API_GUID || matrix.nr == 'worker' && secrets.NEW_RELIC_Worker_GUID }} + version: '${{ github.sha }}' + user: '${{ github.actor }}' + description: 'Novu Cloud Deployment' From b7d6dafe0ce4db8865b511943bc2ebe7a5b3e2fc Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 13:35:51 +0530 Subject: [PATCH 25/40] fix(deploy): update environment matrix to use full environment array --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cbee884a8db..54f843b9b84 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -258,9 +258,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} + env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} - environment: ${{ matrix.env }} steps: From 6f2d0d3e3f01e97b8e8437a5cbe3d0d1529eedba Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 13:48:19 +0530 Subject: [PATCH 26/40] fix(deploy): correct environment variable assignment and add sync state job --- .github/workflows/deploy.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 54f843b9b84..678d0386a04 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -258,9 +258,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} - environment: ${{ matrix.env }} + environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} steps: - name: Checkout @@ -304,3 +303,15 @@ jobs: version: '${{ github.sha }}' user: '${{ github.actor }}' description: 'Novu Cloud Deployment' + + sync_novu_state: + needs: [deploy, prepare-matrix] + runs-on: ubuntu-latest + if: github.event.inputs.deploy_api == 'true' + environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} + steps: + - name: Sync State to Novu + uses: novuhq/actions-novu-sync@v2 + with: + secret-key: ${{ secrets.NOVU_INTERNAL_SECRET_KEY }} + bridge-url: ${{ vars.NOVU_BRIDGE_URL }} From 5f0c465283a77d115321e8da445f3ae7357cac59 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 13:49:58 +0530 Subject: [PATCH 27/40] fix(deploy): add condition to new_relic_release job to check for non-empty nr_matrix --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 678d0386a04..f7b37df5560 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -286,6 +286,7 @@ jobs: new_relic_release: needs: [deploy, prepare-matrix] + if: ${{ fromJson(needs.prepare-matrix.outputs.nr_matrix) != '[]' }} runs-on: ubuntu-latest strategy: matrix: From 4f041fafc608d5fa92326148b195574e6489fcfc Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 13:56:44 +0530 Subject: [PATCH 28/40] fix(docker): remove unnecessary COPY command for packages/client in Dockerfile --- apps/ws/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/ws/Dockerfile b/apps/ws/Dockerfile index 84f0af42323..ed5255798d1 100644 --- a/apps/ws/Dockerfile +++ b/apps/ws/Dockerfile @@ -10,7 +10,6 @@ COPY --chown=1000:1000 libs/dal ./libs/dal COPY --chown=1000:1000 packages/shared ./packages/shared COPY --chown=1000:1000 libs/testing ./libs/testing COPY --chown=1000:1000 libs/application-generic ./libs/application-generic -COPY --chown=1000:1000 packages/client ./packages/client COPY --chown=1000:1000 packages/framework ./packages/framework COPY --chown=1000:1000 packages/stateless ./packages/stateless COPY --chown=1000:1000 packages/providers ./packages/providers From dbfcda44f70b9f143df396552c13337e4891131e Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 17:52:04 +0530 Subject: [PATCH 29/40] fix(deploy): add run-name to deployment workflow for better clarity --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f7b37df5560..7cc1902dc86 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,6 @@ name: Deploy to Novu Cloud +run-name: Deploy to api ${{github.event.inputs.deploy_api}} worker ${{github.event.inputs.deploy_worker}} ws ${{github.event.inputs.deploy_ws}} webhook ${{github.event.inputs.deploy_webhook}} to ${{github.event.inputs.environment}} + on: workflow_dispatch: inputs: From 0e5b5447cd39c48a780a29382dbaf864fd863395 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 17:55:17 +0530 Subject: [PATCH 30/40] fix(deploy): improve run-name formatting for better readability --- .github/workflows/deploy.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7cc1902dc86..09131b55c30 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,9 @@ name: Deploy to Novu Cloud -run-name: Deploy to api ${{github.event.inputs.deploy_api}} worker ${{github.event.inputs.deploy_worker}} ws ${{github.event.inputs.deploy_ws}} webhook ${{github.event.inputs.deploy_webhook}} to ${{github.event.inputs.environment}} +run-name: Deploy to [api- ${{github.event.inputs.deploy_api}}], [worker- ${{github.event.inputs.deploy_worker}}], [ws- ${{github.event.inputs.deploy_ws}}], [webhook- ${{github.event.inputs.deploy_webhook}}] on [${{ github.event.inputs.environment }}] +description: | + This workflow deploys the Novu Cloud application to different environments and services based on the selected options. + It builds Docker images, pushes them to Amazon ECR, and deploys them to Amazon ECS. + Additionally, it creates Sentry releases and New Relic deployment markers. on: workflow_dispatch: From 7d41ada74ff910a201534f5d60a1e4528fcabb82 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 18:09:41 +0530 Subject: [PATCH 31/40] fix(deploy): improve run-name formatting for better clarity --- .github/workflows/deploy.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 09131b55c30..4f76978dc90 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,15 @@ name: Deploy to Novu Cloud -run-name: Deploy to [api- ${{github.event.inputs.deploy_api}}], [worker- ${{github.event.inputs.deploy_worker}}], [ws- ${{github.event.inputs.deploy_ws}}], [webhook- ${{github.event.inputs.deploy_webhook}}] on [${{ github.event.inputs.environment }}] +run-name: > + Deploy to + ${{ + github.event.inputs.deploy_api == 'true' && 'api, ' || '' + }}${{ + github.event.inputs.deploy_worker == 'true' && 'worker, ' || '' + }}${{ + github.event.inputs.deploy_ws == 'true' && 'ws, ' || '' + }}${{ + github.event.inputs.deploy_webhook == 'true' && 'webhook, ' || '' + }}on ${{ github.event.inputs.environment }} description: | This workflow deploys the Novu Cloud application to different environments and services based on the selected options. It builds Docker images, pushes them to Amazon ECR, and deploys them to Amazon ECS. From b3e467691ca78a82d3604c7c97bc63f5bb2cca33 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 18:12:00 +0530 Subject: [PATCH 32/40] fix(deploy): update run-name for clarity and add condition to build job --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4f76978dc90..2c233b46ee9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,6 +1,6 @@ name: Deploy to Novu Cloud run-name: > - Deploy to + Deploying to ${{ github.event.inputs.deploy_api == 'true' && 'api, ' || '' }}${{ @@ -155,6 +155,7 @@ jobs: build: needs: prepare-matrix + if: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service != '[]' }} timeout-minutes: 60 runs-on: ubuntu-latest environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} From dad2fdc55e1431a6a54662e8c1ef8c1b000be47d Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 18:14:22 +0530 Subject: [PATCH 33/40] fix(deploy): add check for empty service matrix to prevent deployment errors --- .github/workflows/deploy.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2c233b46ee9..555703f23bd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -148,6 +148,11 @@ jobs: IFS=','; echo "${nr[*]}" )]" + if service_matrix == "{\"service\": []}"; then + echo "No services selected. Exiting." + exit 1 + fi + echo "env_matrix=$env_matrix" >> $GITHUB_OUTPUT echo "service_matrix=$service_matrix" >> $GITHUB_OUTPUT echo "deploy_matrix=$deploy_matrix" >> $GITHUB_OUTPUT @@ -155,7 +160,6 @@ jobs: build: needs: prepare-matrix - if: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service != '[]' }} timeout-minutes: 60 runs-on: ubuntu-latest environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} From 0f1717e2314a6085a8e82b693d5a7d3187955ab5 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 18:19:37 +0530 Subject: [PATCH 34/40] fix(deploy): add validation to ensure at least one service is selected for deployment --- .github/workflows/deploy.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 555703f23bd..9a42eed0c84 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -59,6 +59,16 @@ jobs: deploy_matrix: ${{ steps.set-matrix.outputs.deploy_matrix }} nr_matrix: ${{ steps.set-matrix.outputs.nr_matrix }} steps: + - name: Validate Selected Services + run: | + if [ "${{ github.event.inputs.deploy_api }}" != "true" ] && \ + [ "${{ github.event.inputs.deploy_worker }}" != "true" ] && \ + [ "${{ github.event.inputs.deploy_ws }}" != "true" ] && \ + [ "${{ github.event.inputs.deploy_webhook }}" != "true" ]; then + echo "Error: At least one service must be selected for deployment." + exit 1 + fi + - name: Generate Environment, Service, and Deploy Matrices id: set-matrix env: @@ -67,6 +77,7 @@ jobs: envs=() services=() deploy_matrix=() + nr=() # Collect selected environments if [ "${{ github.event.inputs.environment }}" == "staging" ]; then @@ -147,12 +158,6 @@ jobs: nr_matrix="[$( IFS=','; echo "${nr[*]}" )]" - - if service_matrix == "{\"service\": []}"; then - echo "No services selected. Exiting." - exit 1 - fi - echo "env_matrix=$env_matrix" >> $GITHUB_OUTPUT echo "service_matrix=$service_matrix" >> $GITHUB_OUTPUT echo "deploy_matrix=$deploy_matrix" >> $GITHUB_OUTPUT From 16ad67d6df6f3a57293da08cac5575719a5bd3d0 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 18:49:39 +0530 Subject: [PATCH 35/40] fix(rollback): enhance rollback workflow to validate selected services and improve run-name formatting --- .github/workflows/rollback.yml | 463 +++++++++++++++------------------ 1 file changed, 203 insertions(+), 260 deletions(-) diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml index f504ad0b270..099894548a5 100644 --- a/.github/workflows/rollback.yml +++ b/.github/workflows/rollback.yml @@ -1,288 +1,231 @@ -name: Rollback -run-name: Rollback the ${{ inputs.service }} service in the ${{ inputs.environment }} environment - -env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} +name: Rollback Deployment +run-name: > + Rollback + ${{ + github.event.inputs.rollback_api == 'true' && 'api, ' || '' + }}${{ + github.event.inputs.rollback_worker == 'true' && 'worker, ' || '' + }}${{ + github.event.inputs.rollback_ws == 'true' && 'ws, ' || '' + }}${{ + github.event.inputs.rollback_webhook == 'true' && 'webhook, ' || '' + }}on ${{ github.event.inputs.environment }} on: workflow_dispatch: inputs: - service: - type: choice - description: Select service to rollback. - options: - - inbound_mail - - api - - web - - webhook - - widget - - worker - - ws environment: + description: 'Environment to rollback' + required: true type: choice - description: Select the environment - options: - - Production - - Development - region: - type: choice - description: Select the environment region. Required only in production. - options: - - [EU, US] - - [EU] - - [US] - mode: - type: choice - description: The Rollback mode. You can roll back to the previously deployed version or to the version that has the current commit hash of this branch in an image tag name or a deployment info. + default: staging options: - - Previous Version - - Commit Hash + - staging + - production-us + - production-eu + - production-both + + rollback_api: + description: 'Rollback API' + required: true + type: boolean + default: true + + rollback_worker: + description: 'Rollback Worker' + required: true + type: boolean + default: true + + rollback_ws: + description: 'Rollback WS' + required: true + type: boolean + default: true + + rollback_webhook: + description: 'Rollback Webhook' + required: true + type: boolean + default: true jobs: - ecs: - if: contains(fromJson('["api", "inbound_mail", "webhook", "worker", "ws"]'), github.event.inputs.service) + prepare-matrix: runs-on: ubuntu-latest - strategy: - matrix: - region: ${{ fromJSON(github.event.inputs.region) }} - timeout-minutes: 60 - environment: ${{ github.event.inputs.environment }} - permissions: - contents: read - packages: write - deployments: write + outputs: + env_matrix: ${{ steps.set-matrix.outputs.env_matrix }} + service_matrix: ${{ steps.set-matrix.outputs.service_matrix }} + rollback_matrix: ${{ steps.set-matrix.outputs.rollback_matrix }} steps: - - run: echo "Rolling back ${{ github.event.inputs.service }} in ${{ github.event.inputs.environment }}" - - - id: commit - if: contains(fromJson('["Commit Hash"]'), github.event.inputs.mode) - uses: prompt/actions-commit-hash@v3 - - - name: Prepare variables - id: variables + - name: Validate Selected Services run: | - if [[ "${{ matrix.region }}" == "EU" && "${{ github.event.inputs.environment }}" == "Production" ]]; then - echo "Using Terraform Workspace: novu-prod-eu" - echo "TF_WORKSPACE=novu-prod-eu" >> $GITHUB_ENV - elif [[ "${{ matrix.region }}" == "US" && "${{ github.event.inputs.environment }}" == "Production" ]]; then - echo "Using Terraform Workspace: novu-prod" - echo "TF_WORKSPACE=novu-prod" >> $GITHUB_ENV - elif [[ "${{ matrix.region }}" == "EU" && "${{ github.event.inputs.environment }}" == "Development" ]]; then - echo "Using Terraform Workspace: novu-dev" - echo "TF_WORKSPACE=novu-dev" >> $GITHUB_ENV - elif [[ "${{ matrix.region }}" == "US" && "${{ github.event.inputs.environment }}" == "Development" ]]; then - echo "Using Terraform Workspace: novu-dev" - echo "TF_WORKSPACE=novu-dev" >> $GITHUB_ENV - echo "Error: Development environment doesn't exist in the US region." >&2 + if [ "${{ github.event.inputs.rollback_api }}" != "true" ] && \ + [ "${{ github.event.inputs.rollback_worker }}" != "true" ] && \ + [ "${{ github.event.inputs.rollback_ws }}" != "true" ] && \ + [ "${{ github.event.inputs.rollback_webhook }}" != "true" ]; then + echo "Error: At least one service must be selected for rollback." exit 1 - else - echo "Using Terraform Workspace: novu-dev" - echo "TF_WORKSPACE=novu-dev" >> $GITHUB_ENV fi - - - name: Checkout cloud infra - uses: actions/checkout@master - with: - repository: novuhq/cloud-infra - token: ${{ secrets.GH_PACKAGES }} - path: cloud-infra - - - name: Terraform setup - uses: hashicorp/setup-terraform@v3 - with: - cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} - terraform_version: 1.5.5 - terraform_wrapper: false - - - name: Terraform Init - working-directory: cloud-infra/terraform/novu/aws - run: terraform init - - - name: Terraform get output - working-directory: cloud-infra/terraform/novu/aws - id: terraform - env: - SERVICE_NAME: ${{ github.event.inputs.service }} - run: | - echo "ecs_container_name=$(terraform output -json ${{ env.SERVICE_NAME }}_ecs_container_name | jq -r .)" >> $GITHUB_ENV - echo "ecs_service=$(terraform output -json ${{ env.SERVICE_NAME }}_ecs_service | jq -r .)" >> $GITHUB_ENV - echo "ecs_cluster=$(terraform output -json ${{ env.SERVICE_NAME }}_ecs_cluster | jq -r .)" >> $GITHUB_ENV - echo "task_name=$(terraform output -json ${{ env.SERVICE_NAME }}_task_name | jq -r .)" >> $GITHUB_ENV - echo "aws_region=$(terraform output -json aws_region | jq -r .)" >> $GITHUB_ENV - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.aws_region }} - - - name: ECS get output - if: contains(fromJson('["Previous Version"]'), github.event.inputs.mode) - id: ecs-output + + - name: Generate Environment, Service, and Rollback Matrices + id: set-matrix + env: + WORKER_SERVICE: ${{ vars.WORKER_SERVICE }} run: | - echo "Retrieving current_task_definition_arn..." - current_task_definition_arn=$(aws ecs describe-services --cluster ${{ env.ecs_cluster }} --services ${{ env.ecs_service }} --query 'services[0].taskDefinition' --output text) - echo "current_task_definition_arn=$current_task_definition_arn" >> $GITHUB_ENV + envs=() + services=() + rollback_matrix=() - echo "Retrieving task_definition_family..." - task_definition_family=$(aws ecs describe-task-definition --task-definition ${{ env.task_name }} --query 'taskDefinition.family' --output text) - echo "task_definition_family=$task_definition_family" >> $GITHUB_ENV - - echo "Retrieving task_definition_list..." - task_definition_list=$(aws ecs list-task-definitions --family-prefix "${task_definition_family}" --output text --sort DESC | grep 'TASKDEFINITIONARNS' | cut -f 2) - task_definition_list_formatted=$(echo "$task_definition_list" | tr '\n' '|') # Replace newline with '|' - echo "task_definition_list=$task_definition_list_formatted" >> $GITHUB_ENV + # Collect selected environments + if [ "${{ github.event.inputs.environment }}" == "staging" ]; then + envs+=("\"staging-eu\"") + fi + if [ "${{ github.event.inputs.environment }}" == "production-us" ]; then + envs+=("\"prod-us\"") + fi + if [ "${{ github.event.inputs.environment }}" == "production-eu" ]; then + envs+=("\"prod-eu\"") + fi + if [ "${{ github.event.inputs.environment }}" == "production-both" ]; then + envs+=("\"prod-us\"") + envs+=("\"prod-eu\"") + fi - if [ -n "$task_definition_list" ]; then - echo "Retrieving previous_task_definition_arn..." - index=$(echo "$task_definition_list" | grep -n "$current_task_definition_arn" | cut -d ':' -f 1) - if [ -n "$index" ]; then - if [ "$index" -ge 1 ]; then # Greater than or equal to 1 - previous_index=$((index + 1)) - previous_task_definition_arn=$(echo "$task_definition_list" | sed -n "${previous_index}p") - echo "previous_task_definition_arn=$previous_task_definition_arn" >> $GITHUB_ENV - else - echo "Invalid index value: $index" - fi - else - echo "Previous task definition not found. It seems to me someone deleted the current task from the list and that is why I can't find the previous task." - exit 1 - fi - else - echo "No task definitions found." - exit 1 + # Collect selected services + if [ "${{ github.event.inputs.rollback_api }}" == "true" ]; then + services+=("\"api\"") + fi + if [ "${{ github.event.inputs.rollback_worker }}" == "true" ]; then + services+=("\"worker\"") + fi + if [ "${{ github.event.inputs.rollback_ws }}" == "true" ]; then + services+=("\"ws\"") + fi + if [ "${{ github.event.inputs.rollback_webhook }}" == "true" ]; then + services+=("\"webhook\"") fi - - name: ECS get output by using commit hash - if: contains(fromJson('["Commit Hash"]'), github.event.inputs.mode) - id: ecs-output-commit-hash - env: - IMAGE_TAG: ${{ steps.commit.outputs.hash }} - run: | - task_definition_family=$(aws ecs describe-task-definition --task-definition ${{ env.task_name }} --query 'taskDefinition.family' --output text) - task_definition_arns=$(aws ecs list-task-definitions --family-prefix "${task_definition_family}" --query 'taskDefinitionArns' --output text --sort DESC) - found=false - for arn in $(echo "$task_definition_arns" | tr '\t' '\n' | head -n 20); do - task_definition=$(aws ecs describe-task-definition --task-definition $arn) - if echo "$task_definition" | grep -q "$IMAGE_TAG"; then - echo "Found task definition with image tag $IMAGE_TAG: $arn" - found=true - needed_arn=$arn - break + # Parse service secrets and generate rollback_matrix + for service in "${services[@]}"; do + if [ "$service" == "\"worker\"" ]; then + IFS=',' read -r -a worker_services <<< "$WORKER_SERVICE" + for worker_service in $(echo "$WORKER_SERVICE" | jq -c '.[]'); do + cluster_name=$(echo "$worker_service" | jq -r '.cluster_name') + container_name=$(echo "$worker_service" | jq -r '.container_name') + service_name=$(echo "$worker_service" | jq -r '.service') + task_name=$(echo "$worker_service" | jq -r '.task_name') + image=$(echo "$worker_service" | jq -r '.image') + rollback_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") + done + elif [ "$service" == "\"api\"" ]; then + cluster_name=api-cluster + container_name=api-container + service_name=api-service + task_name=api-task + image=api + rollback_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") + elif [ "$service" == "\"ws\"" ]; then + cluster_name=ws-cluster + container_name=ws-container + service_name=ws-service + task_name=ws-task + image=ws + rollback_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") + elif [ "$service" == "\"webhook\"" ]; then + cluster_name=webhook-cluster + container_name=webhook-container + service_name=webhook-service + task_name=webhook-task + image=webhook + rollback_matrix+=("{\"cluster_name\": \"$cluster_name\", \"container_name\": \"$container_name\", \"service_name\": \"$service_name\", \"task_name\": \"$task_name\", \"image\": \"$image\"}") fi done - if [ "$found" = false ]; then - echo "Error: Task definition with image tag $IMAGE_TAG not found within the last 20 tasks." - exit 1 - fi - current_task_definition_arn=$(aws ecs describe-services --cluster ${{ env.ecs_cluster }} --services ${{ env.ecs_service }} --query 'services[0].taskDefinition' --output text) - echo "current_task_definition_arn=$current_task_definition_arn" >> $GITHUB_ENV - echo "previous_task_definition_arn=$needed_arn" >> $GITHUB_ENV - echo "Your task definition ARN is $needed_arn" - - name: Rollback a service to the previous task definition - id: rollback - env: - PREVIOUS_TASK: ${{ env.previous_task_definition_arn }} - CURRENT_TASK: ${{ env.current_task_definition_arn }} - run: | - aws ecs update-service --cluster ${{ env.ecs_cluster }} --service ${{ env.ecs_service }} --task-definition ${{ env.PREVIOUS_TASK }} - aws ecs wait services-stable --cluster ${{ env.ecs_cluster }} --service ${{ env.ecs_service }} - echo "After Rollback:" - echo "The previous task definition: $(echo $CURRENT_TASK | awk -F'task-definition/' '{print $2}')" - echo "The current task definition: $(echo $PREVIOUS_TASK | awk -F'task-definition/' '{print $2}')" - - netlify: - if: contains(fromJson('["web", "widget"]'), github.event.inputs.service) + env_matrix="{\"environment\": [$( + IFS=','; echo "${envs[*]}" + )]}" + service_matrix="{\"service\": [$( + IFS=','; echo "${services[*]}" + )]}" + rollback_matrix="[$( + IFS=','; echo "${rollback_matrix[*]}" + )]" + echo "env_matrix=$env_matrix" >> $GITHUB_OUTPUT + echo "service_matrix=$service_matrix" >> $GITHUB_OUTPUT + echo "rollback_matrix=$rollback_matrix" >> $GITHUB_OUTPUT + + rollback: + needs: [prepare-matrix] runs-on: ubuntu-latest strategy: matrix: - region: ${{ fromJSON(github.event.inputs.region) }} - timeout-minutes: 60 - environment: ${{ github.event.inputs.environment }} - permissions: - contents: read - packages: write - deployments: write - env: - NETLIFY_ACCESS_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - steps: - - run: echo "Rolling back ${{ github.event.inputs.service }} in ${{ github.event.inputs.environment }}" - - - id: commit-netlify - if: contains(fromJson('["Commit Hash"]'), github.event.inputs.mode) - uses: prompt/actions-commit-hash@v3 + env: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment }} + service: ${{ fromJson(needs.prepare-matrix.outputs.rollback_matrix) }} - - name: Prepare variables - id: variables - run: | - if [[ "${{ github.event.inputs.service }}" == "widget" && "${{ github.event.inputs.environment }}" == "Development" && "${{ matrix.region }}" == "EU" ]]; then - echo "Using netlify_site_id: b9147448-b835-4eb1-a2f0-11102f611f5f" - echo "netlify_site_id=b9147448-b835-4eb1-a2f0-11102f611f5f" >> $GITHUB_ENV - elif [[ "${{ github.event.inputs.service }}" == "web" && "${{ github.event.inputs.environment }}" == "Development" && "${{ matrix.region }}" == "EU" ]]; then - echo "Using netlify_site_id: 45396446-dc86-4ad6-81e4-86d3eb78d06f" - echo "netlify_site_id=45396446-dc86-4ad6-81e4-86d3eb78d06f" >> $GITHUB_ENV - elif [[ "${{ github.event.inputs.environment }}" == "Development" && "${{ matrix.region }}" == "US" ]]; then - echo "Error: Development environment doesn't exist in the US region." >&2 - exit 1 - elif [[ "${{ github.event.inputs.service }}" == "web" && "${{ github.event.inputs.environment }}" == "Production" && "${{ matrix.region }}" == "EU" ]]; then - echo "Using netlify_site_id: d2e8b860-7016-4202-9256-ebca0f13259a" - echo "netlify_site_id=d2e8b860-7016-4202-9256-ebca0f13259a" >> $GITHUB_ENV - elif [[ "${{ github.event.inputs.service }}" == "web" && "${{ github.event.inputs.environment }}" == "Production" && "${{ matrix.region }}" == "US" ]]; then - echo "Using netlify_site_id: 8639d8b9-81f9-44c3-b885-585a7fd2b5ff" - echo "netlify_site_id=8639d8b9-81f9-44c3-b885-585a7fd2b5ff" >> $GITHUB_ENV - elif [[ "${{ github.event.inputs.service }}" == "widget" && "${{ github.event.inputs.environment }}" == "Production" && "${{ matrix.region }}" == "EU" ]]; then - echo "Using netlify_site_id: 20a64bdd-1934-4284-875f-862410c69a3b" - echo "netlify_site_id=20a64bdd-1934-4284-875f-862410c69a3b" >> $GITHUB_ENV - elif [[ "${{ github.event.inputs.service }}" == "widget" && "${{ github.event.inputs.environment }}" == "Production" && "${{ matrix.region }}" == "US" ]]; then - echo "Using netlify_site_id: 6f927fd4-dcb0-4cf3-8c0b-8c5539d0d034" - echo "netlify_site_id=6f927fd4-dcb0-4cf3-8c0b-8c5539d0d034" >> $GITHUB_ENV - fi + environment: ${{ matrix.env }} - - name: Get Current Deploy ID - if: contains(fromJson('["Previous Version"]'), github.event.inputs.mode) - id: get_current_deploy - env: - NETLIFY_SITE_ID: ${{ env.netlify_site_id }} - run: | - response=$(curl -s -H "Authorization: Bearer $NETLIFY_ACCESS_TOKEN" "https://api.netlify.com/api/v1/sites/${NETLIFY_SITE_ID}") - current_deploy_id=$(echo "$response" | jq -r '.published_deploy.id') - echo "current_deploy_id=$current_deploy_id" >> $GITHUB_ENV - - - name: Find Previous Production Deployments and Determine Previous Deploy ID - if: contains(fromJson('["Previous Version"]'), github.event.inputs.mode) - id: previous_deploy_id - env: - NETLIFY_SITE_ID: ${{ env.netlify_site_id }} - run: | - response=$(curl -s -H "Authorization: Bearer $NETLIFY_ACCESS_TOKEN" "https://api.netlify.com/api/v1/sites/${NETLIFY_SITE_ID}/deploys?per_page=100") - deploy_ids=$(echo "$response" | jq -r '.[] | select(.context == "production" and .state == "ready" and .published_at != null) | .id' | sort) - current_index=$(echo "$deploy_ids" | grep -n "$current_deploy_id" | cut -d ":" -f 1) - previous_index=$((current_index - 1)) - previous_deploy_id=$(echo "$deploy_ids" | sed "${previous_index}q;d") - echo "previous_deploy_id=$previous_deploy_id" >> $GITHUB_ENV - - - name: Determine Previous Deploy ID - if: contains(fromJson('["Commit Hash"]'), github.event.inputs.mode) - env: - NETLIFY_SITE_ID: ${{ env.netlify_site_id }} - COMMIT_REF: ${{ steps.commit-netlify.outputs.hash }} - run: | - response=$(curl -s -H "Authorization: Bearer $NETLIFY_ACCESS_TOKEN" "https://api.netlify.com/api/v1/sites/$NETLIFY_SITE_ID/deploys") - deploy_id=$(echo "$response" | jq -r ".[] | select(.commit_ref == \"$COMMIT_REF\") | .id") - if [ -n "$deploy_id" ]; then - echo "Deploy ID for commit $COMMIT_REF: $deploy_id" - echo "previous_deploy_id=$deploy_id" >> $GITHUB_ENV - else - echo "Deploy not found for commit $COMMIT_REF" + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.AWS_REGION }} + + - name: ECS get output + env: + TASK_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.task_name }} + CONTAINER_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.container_name }} + SERVICE_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.service_name }} + CLUSTER_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.cluster_name }} + id: ecs-output + run: | + echo "Retrieving current_task_definition_arn..." + current_task_definition_arn=$(aws ecs describe-services --cluster ${CLUSTER_NAME} --services ${SERVICE_NAME} --query 'services[0].taskDefinition' --output text) + echo "current_task_definition_arn=$current_task_definition_arn" >> $GITHUB_ENV + + echo "Retrieving task_definition_family..." + task_definition_family=$(aws ecs describe-task-definition --task-definition ${TASK_NAME} --query 'taskDefinition.family' --output text) + echo "task_definition_family=$task_definition_family" >> $GITHUB_ENV + + echo "Retrieving task_definition_list..." + task_definition_list=$(aws ecs list-task-definitions --family-prefix "${task_definition_family}" --output text --sort DESC | grep 'TASKDEFINITIONARNS' | cut -f 2) + task_definition_list_formatted=$(echo "$task_definition_list" | tr '\n' '|') # Replace newline with '|' + echo "task_definition_list=$task_definition_list_formatted" >> $GITHUB_ENV + + if [ -n "$task_definition_list" ]; then + echo "Retrieving previous_task_definition_arn..." + index=$(echo "$task_definition_list" | grep -n "$current_task_definition_arn" | cut -d ':' -f 1) + if [ -n "$index" ]; then + if [ "$index" -ge 1 ]; then # Greater than or equal to 1 + previous_index=$((index + 1)) + previous_task_definition_arn=$(echo "$task_definition_list" | sed -n "${previous_index}p") + echo "previous_task_definition_arn=$previous_task_definition_arn" >> $GITHUB_ENV + else + echo "Invalid index value: $index" + fi + else + echo "Previous task definition not found. It seems to me someone deleted the current task from the list and that is why I can't find the previous task." + exit 1 + fi + else + echo "No task definitions found." exit 1 - fi - - - name: Rollback to Previous Deploy - if: env.previous_deploy_id != null - env: - NETLIFY_SITE_ID: ${{ env.netlify_site_id }} - run: | - echo "Restoring previous deploy..." - curl -X POST -H "Authorization: Bearer $NETLIFY_ACCESS_TOKEN" "https://api.netlify.com/api/v1/sites/${{ env.netlify_site_id }}/deploys/${{ env.previous_deploy_id }}/restore" + fi + + - name: Rollback a service to the previous task definition + id: rollback-service + env: + PREVIOUS_TASK: ${{ env.previous_task_definition_arn }} + CURRENT_TASK: ${{ env.current_task_definition_arn }} + SERVICE_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.service_name }} + CLUSTER_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.cluster_name }} + run: | + aws ecs update-service --cluster ${CLUSTER_NAME}--service ${SERVICE_NAME} --task-definition ${{ env.PREVIOUS_TASK }} + aws ecs wait services-stable --cluster ${CLUSTER_NAME} --service ${SERVICE_NAME} + echo "After Rollback:" + echo "The previous task definition: $(echo $CURRENT_TASK | awk -F'task-definition/' '{print $2}')" + echo "The current task definition: $(echo $PREVIOUS_TASK | awk -F'task-definition/' '{print $2}')" + echo "Rollback completed successfully." + + \ No newline at end of file From f0e2b65e3692d47b5fa9b4fb751ca7609bad7d8b Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 18:52:59 +0530 Subject: [PATCH 36/40] fix(rollback): correct syntax in AWS CLI command for updating service during rollback --- .github/workflows/rollback.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml index 099894548a5..6fdc55bc308 100644 --- a/.github/workflows/rollback.yml +++ b/.github/workflows/rollback.yml @@ -221,7 +221,7 @@ jobs: SERVICE_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.service_name }} CLUSTER_NAME: ${{ vars.ECS_PREFIX }}-${{ matrix.service.cluster_name }} run: | - aws ecs update-service --cluster ${CLUSTER_NAME}--service ${SERVICE_NAME} --task-definition ${{ env.PREVIOUS_TASK }} + aws ecs update-service --cluster ${CLUSTER_NAME} --service ${SERVICE_NAME} --task-definition ${{ env.PREVIOUS_TASK }} aws ecs wait services-stable --cluster ${CLUSTER_NAME} --service ${SERVICE_NAME} echo "After Rollback:" echo "The previous task definition: $(echo $CURRENT_TASK | awk -F'task-definition/' '{print $2}')" From cd8ad97ce9aefebc6229d3587f56cc9a5c5993ef Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 19:02:53 +0530 Subject: [PATCH 37/40] fix(rollback): remove trailing comma from webhook in run-name and update environment description --- .github/workflows/deploy.yml | 2 +- .github/workflows/rollback.yml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9a42eed0c84..76d09f65c82 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,7 +8,7 @@ run-name: > }}${{ github.event.inputs.deploy_ws == 'true' && 'ws, ' || '' }}${{ - github.event.inputs.deploy_webhook == 'true' && 'webhook, ' || '' + github.event.inputs.deploy_webhook == 'true' && 'webhook ' || '' }}on ${{ github.event.inputs.environment }} description: | This workflow deploys the Novu Cloud application to different environments and services based on the selected options. diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml index 6fdc55bc308..dfb394ef13b 100644 --- a/.github/workflows/rollback.yml +++ b/.github/workflows/rollback.yml @@ -8,14 +8,17 @@ run-name: > }}${{ github.event.inputs.rollback_ws == 'true' && 'ws, ' || '' }}${{ - github.event.inputs.rollback_webhook == 'true' && 'webhook, ' || '' + github.event.inputs.rollback_webhook == 'true' && 'webhook ' || '' }}on ${{ github.event.inputs.environment }} +description: Rollback deployment to the previous task definition for selected services in the specified environment. +concurrency: + group: "rollback-${{ github.event.inputs.environment }}" on: workflow_dispatch: inputs: environment: - description: 'Environment to rollback' + description: 'Environment to rollback. This will not rollback any environment variable changes. Only the task definition will be rolled back.' required: true type: choice default: staging From 9bf8515a5644f17a90bbcdb3779293480cc887ca Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 19:07:21 +0530 Subject: [PATCH 38/40] fix(rollback): update environment description and add rollback signoff input for clarity --- .github/workflows/rollback.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml index dfb394ef13b..04a0665f442 100644 --- a/.github/workflows/rollback.yml +++ b/.github/workflows/rollback.yml @@ -18,7 +18,7 @@ on: workflow_dispatch: inputs: environment: - description: 'Environment to rollback. This will not rollback any environment variable changes. Only the task definition will be rolled back.' + description: 'Environment to rollback' required: true type: choice default: staging @@ -51,10 +51,20 @@ on: required: true type: boolean default: true - + + rollback_signoff: + description: "This will rollback the selected services to the previous task definition. This won't rollback any database migration or environment changes. Do you want to continue?" + required: true + type: choice + default: no + options: + - yes + - no + jobs: prepare-matrix: runs-on: ubuntu-latest + if : ${{ github.event.inputs.rollback_signoff == 'yes' }} outputs: env_matrix: ${{ steps.set-matrix.outputs.env_matrix }} service_matrix: ${{ steps.set-matrix.outputs.service_matrix }} From e4b620bd3509b4f437798691b9c071f358274f5f Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Mon, 14 Apr 2025 19:09:56 +0530 Subject: [PATCH 39/40] fix(rollback): update rollback signoff description and options for clarity --- .github/workflows/rollback.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml index 04a0665f442..7e5ee1fa397 100644 --- a/.github/workflows/rollback.yml +++ b/.github/workflows/rollback.yml @@ -53,18 +53,19 @@ on: default: true rollback_signoff: - description: "This will rollback the selected services to the previous task definition. This won't rollback any database migration or environment changes. Do you want to continue?" + description: "This will rollback the selected services to the previous task definition. This won't rollback any database migration or environment changes. Do you agree?" required: true type: choice - default: no + default: 'I do not agree' options: - - yes - - no + - 'I agree' + - 'I do not agree' + jobs: prepare-matrix: runs-on: ubuntu-latest - if : ${{ github.event.inputs.rollback_signoff == 'yes' }} + if : "${{ github.event.inputs.rollback_signoff == 'I agree' }}" outputs: env_matrix: ${{ steps.set-matrix.outputs.env_matrix }} service_matrix: ${{ steps.set-matrix.outputs.service_matrix }} From a7042529cb6cd95c693a50e59cd87b2dba6c2794 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Thu, 17 Apr 2025 14:06:42 +0530 Subject: [PATCH 40/40] fix(deploy): remove unnecessary outputs and echo command from build job --- .github/workflows/deploy.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 76d09f65c82..f92d8108e62 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -168,8 +168,6 @@ jobs: timeout-minutes: 60 runs-on: ubuntu-latest environment: ${{ fromJson(needs.prepare-matrix.outputs.env_matrix).environment[0] }} - outputs: - registry: ${{ steps.build-image.outputs.registry }} strategy: matrix: service: ${{ fromJson(needs.prepare-matrix.outputs.service_matrix).service }} @@ -234,7 +232,6 @@ jobs: docker tag novu-$SERVICE $REGISTRY/$REPOSITORY/$SERVICE:$IMAGE_TAG docker push $REGISTRY/$REPOSITORY/$SERVICE:latest docker push $REGISTRY/$REPOSITORY/$SERVICE:$IMAGE_TAG - echo "registry=$REGISTRY/$REPOSITORY" >> $GITHUB_OUTPUT deploy: needs: [build, prepare-matrix]