diff --git a/.github/actions/deploy-ecs/action.yaml b/.github/actions/deploy-ecs/action.yaml new file mode 100644 index 0000000000..649e6775a1 --- /dev/null +++ b/.github/actions/deploy-ecs/action.yaml @@ -0,0 +1,60 @@ +name: "Deploy to ECS" +description: "Deploy new image to given ECS service by updating task definition file" +inputs: + aws-role: + required: true + description: "AWS ROLE" + aws-region: + required: true + description: "AWS REGION" + task-definition: + required: true + description: "TASK DEFINITION" + container-name: + required: true + description: "CONTAINER NAME" + ecs-service: + required: true + description: "ECS SERVICE" + ecs-cluster: + required: true + description: "ECS CLUSTER" + image: + required: true + description: "APP IMAGE" +runs: + using: "composite" + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ inputs.aws-role }} + aws-region: ${{ inputs.aws-region }} + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ inputs.task-definition }} \ + --query taskDefinition > task-definition.json + shell: bash + + - name: Fill in the new image ID in the Amazon ECS task definition + id: task_def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: ${{ inputs.container-name }} + image: ${{ inputs.image }} + + - name: Remove unwanted fields from task definition + id: task_def_cleanup + shell: bash + run: | + jq 'del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy)' ${{ steps.task_def.outputs.task-definition }} > updated-task-definition.json + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: updated-task-definition.json + service: ${{ inputs.ecs-service }} + cluster: ${{ inputs.ecs-cluster }} + wait-for-service-stability: true diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000000..f592f390e4 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,34 @@ +# Conductor CI/CD Workflow + +This repository contains workflow files for implementing Continuous Integration (CI) and Continuous Deployment (CD) processes separately for Conductor UI and server components. The workflow is designed to deploy to both development (dev) and production (prd) environments on AWS (ECS). + +## Workflow Overview + +The CI/CD workflow is triggered manually & comprises two main components: + +1. **Conductor UI CI/CD:** + - Workflow file: `.github/workflows/ci-ui.yaml` + `.github/workflows/cd-ui.yaml` + - These workflows handle the CI & CD process for Conductor UI. + +2. **Conductor Server CI/CD:** + - Workflow file: `.github/workflows/ci-server.yaml` + `.github/workflows/cd-server.yaml` + - These workflows handle the CI & CD process for Conductor server. + +## Deployment Strategy + +- **Branches:** + - The `production` branch is considered the master branch for all deployments. + - All deployments to both development and production environments are triggered from the `production` branch. + +- **Input Variables:** + - The workflow takes the following input variables: + 1. **Branch:** Specifies the branch to be deployed (e.g., `production`). + 2. **Environment:** Specifies the deployment environment (e.g., `dev` or `prd`). + 3. **Tag:** Specifies the version to be deployed. This version is used for tagging the Docker image. + +## Versioning and Docker Image Tagging + +The version provided as an input variable is crucial for versioning and tagging Docker images. The workflow utilizes this version to tag the Docker image before deploying to the AWS Elastic Container Registry (ECR). During ECS deployment, this tagged image is fetched from ECR. + diff --git a/.github/workflows/cd-server.yaml b/.github/workflows/cd-server.yaml new file mode 100644 index 0000000000..090a375e6d --- /dev/null +++ b/.github/workflows/cd-server.yaml @@ -0,0 +1,156 @@ +name: Deploy Conductor Server + +on: + workflow_dispatch: + inputs: + Environment: + required: true + type: choice + description: Choose aws env + options: + - dev + - stg + - prd + Tag: + required: true + type: string + description: Provide tag (Eg:v3.14.0) + +env: + SERVICE_NAME: conductor-server + AWS_REGION: "ap-south-1" + + +jobs: + prepare-env: + name: Prepare Env + runs-on: 'ubuntu-latest' + timeout-minutes: 2 + outputs: + AWS_ROLE: ${{ steps.vars.outputs.AWS_ROLE }} + ENV: ${{ steps.vars.outputs.ENV }} + PROJECT_PREFIX: ${{ steps.vars.outputs.PROJECT_PREFIX }} + ECS_CLUSTER: ${{ steps.set_env.outputs.ECS_CLUSTER }} + ECS_SERVICE: ${{ steps.set_env.outputs.ECS_SERVICE }} + TASK_DEFINITION: ${{ steps.set_env.outputs.TASK_DEFINITION }} + CONTAINER_NAME: ${{ steps.set_env.outputs.CONTAINER_NAME }} + ECR_REPOSITORY: ${{ steps.set_env.outputs.ECR_REPOSITORY }} + SLACK_WEBHOOK_URL: ${{ steps.vars.outputs.SLACK_WEBHOOK_URL }} + + steps: + - id: vars + shell: bash + run: | + BRANCH="${GITHUB_REF#refs/heads/}" + ENV=${{ github.event.inputs.environment }} + IMAGE_TAG=${{ github.event.inputs.tag }} + echo $BRANCH + + if [ -z "$ENV" ] + then + case $BRANCH in + "dev") + ENV="dev" + ;; + "stg") + ENV="stg" + ;; + "main") + ENV="prd" + ;; + *) + echo "ENV not configured" && exit 1 + ;; + esac + fi + if [[ $ENV == 'prd' && $BRANCH == 'production' ]] + then + echo "AWS_ROLE=PRD_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-prd-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=PRD_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'stg' ] + then + echo "AWS_ROLE=STG_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-stg-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'dev' ] + then + echo "AWS_ROLE=DEV_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-dev-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + else + echo "Branch not configured!" + exit 1 + fi + echo "ENV=$ENV" >> $GITHUB_OUTPUT + echo ":rocket: Environment - $ENV " >> $GITHUB_STEP_SUMMARY + echo ":label: Image Tag - $IMAGE_TAG " >> $GITHUB_STEP_SUMMARY + - name: set variables + id: set_env + run: | + PROJECT_PREFIX=${{ steps.vars.outputs.PROJECT_PREFIX }} + echo "ECR_REPOSITORY=$PROJECT_PREFIX-ecr-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "ECS_CLUSTER=$PROJECT_PREFIX-ecs-cluster" >> $GITHUB_OUTPUT + echo "ECS_SERVICE=$PROJECT_PREFIX-svc-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "TASK_DEFINITION=$PROJECT_PREFIX-td-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "CONTAINER_NAME=$PROJECT_PREFIX-cntr-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo ":seedling: Branch:${GITHUB_REF#refs/heads/}" >> $GITHUB_STEP_SUMMARY + + # Deploy Conductor UI Image to ECS + deploy-ui-image: + name: Deploy UI Image + runs-on: 'ubuntu-latest' + timeout-minutes: 20 + permissions: + id-token: write + pull-requests: write + contents: read + needs: prepare-env + env: + AWS_ROLE: ${{ needs.prepare-env.outputs.AWS_ROLE }} + ENV: ${{ needs.prepare-env.outputs.ENV }} + PROJECT_PREFIX: ${{needs.prepare-env.outputs.PROJECT_PREFIX}} + ECR_REPOSITORY: ${{needs.prepare-env.outputs.ECR_REPOSITORY}} + IMAGE_TAG: ${{ github.event.inputs.tag }} + ECS_CLUSTER: ${{ needs.prepare-env.outputs.ECS_CLUSTER }} + ECS_SERVICE: ${{ needs.prepare-env.outputs.ECS_SERVICE }} + TASK_DEFINITION: ${{ needs.prepare-env.outputs.TASK_DEFINITION }} + CONTAINER_NAME: ${{ needs.prepare-env.outputs.CONTAINER_NAME }} + + steps: + - name: Checkout code from action + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets[env.AWS_ROLE] }} + aws-region: ${{ env.AWS_REGION }} + + - name: Amazon ECR Login + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1.7.0 + + - name: Check if image tag exists in ECR + id: check-image-existence + run: | + if aws ecr describe-images --repository-name "${{ env.ECR_REPOSITORY }}" --region "${{ env.AWS_REGION }}" --image-ids imageTag="${{ env.IMAGE_TAG }}" 2>&1 | grep -q "imageTag"; then + echo "Image tag $IMAGE_TAG exists in ECR" + else + echo "Error: Image tag $IMAGE_TAG does not exist in ECR" + exit 1 + fi + + - name: Deploy backend + id: deploy_backend + uses: ./.github/actions/deploy-ecs + env: + APP_IMAGE: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + with: + aws-region : ${{ env.AWS_REGION }} + aws-role: ${{ secrets[env.AWS_ROLE] }} + task-definition: ${{ env.TASK_DEFINITION }} + container-name: ${{ env.CONTAINER_NAME }} + ecs-service: ${{ env.ECS_SERVICE }} + ecs-cluster: ${{ env.ECS_CLUSTER }} + image: ${{ env.APP_IMAGE }} \ No newline at end of file diff --git a/.github/workflows/cd-ui.yaml b/.github/workflows/cd-ui.yaml new file mode 100644 index 0000000000..3609423632 --- /dev/null +++ b/.github/workflows/cd-ui.yaml @@ -0,0 +1,155 @@ +name: Deploy Conductor UI + +on: + workflow_dispatch: + inputs: + Environment: + required: true + type: choice + description: Choose aws env + options: + - dev + - stg + - prd + Tag: + required: true + type: string + description: Provide tag (Eg:v3.14.0) + +env: + SERVICE_NAME: conductor-ui + AWS_REGION: "ap-south-1" + +jobs: + prepare-env: + name: Prepare Env + runs-on: 'ubuntu-latest' + timeout-minutes: 2 + outputs: + AWS_ROLE: ${{ steps.vars.outputs.AWS_ROLE }} + ENV: ${{ steps.vars.outputs.ENV }} + PROJECT_PREFIX: ${{ steps.vars.outputs.PROJECT_PREFIX }} + ECS_CLUSTER: ${{ steps.set_env.outputs.ECS_CLUSTER }} + ECS_SERVICE: ${{ steps.set_env.outputs.ECS_SERVICE }} + TASK_DEFINITION: ${{ steps.set_env.outputs.TASK_DEFINITION }} + CONTAINER_NAME: ${{ steps.set_env.outputs.CONTAINER_NAME }} + ECR_REPOSITORY: ${{ steps.set_env.outputs.ECR_REPOSITORY }} + SLACK_WEBHOOK_URL: ${{ steps.vars.outputs.SLACK_WEBHOOK_URL }} + + steps: + - id: vars + shell: bash + run: | + BRANCH="${GITHUB_REF#refs/heads/}" + ENV=${{ github.event.inputs.environment }} + IMAGE_TAG=${{ github.event.inputs.tag }} + echo $BRANCH + + if [ -z "$ENV" ] + then + case $BRANCH in + "dev") + ENV="dev" + ;; + "stg") + ENV="stg" + ;; + "main") + ENV="prd" + ;; + *) + echo "ENV not configured" && exit 1 + ;; + esac + fi + if [[ $ENV == 'prd' && $BRANCH == 'production' ]] + then + echo "AWS_ROLE=PRD_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-prd-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=PRD_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'stg' ] + then + echo "AWS_ROLE=STG_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-stg-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'dev' ] + then + echo "AWS_ROLE=DEV_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-dev-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + else + echo "Branch not configured!" + exit 1 + fi + echo "ENV=$ENV" >> $GITHUB_OUTPUT + echo ":rocket: Environment - $ENV " >> $GITHUB_STEP_SUMMARY + echo ":label: Image Tag - $IMAGE_TAG " >> $GITHUB_STEP_SUMMARY + - name: set variables + id: set_env + run: | + PROJECT_PREFIX=${{ steps.vars.outputs.PROJECT_PREFIX }} + echo "ECR_REPOSITORY=$PROJECT_PREFIX-ecr-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "ECS_CLUSTER=$PROJECT_PREFIX-ecs-cluster" >> $GITHUB_OUTPUT + echo "ECS_SERVICE=$PROJECT_PREFIX-svc-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "TASK_DEFINITION=$PROJECT_PREFIX-td-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "CONTAINER_NAME=$PROJECT_PREFIX-cntr-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo ":seedling: Branch:${GITHUB_REF#refs/heads/}" >> $GITHUB_STEP_SUMMARY + + # Deploy Conductor UI Image to ECS + deploy-ui-image: + name: Deploy UI Image + runs-on: 'ubuntu-latest' + timeout-minutes: 20 + permissions: + id-token: write + pull-requests: write + contents: read + needs: prepare-env + env: + AWS_ROLE: ${{ needs.prepare-env.outputs.AWS_ROLE }} + ENV: ${{ needs.prepare-env.outputs.ENV }} + PROJECT_PREFIX: ${{needs.prepare-env.outputs.PROJECT_PREFIX}} + ECR_REPOSITORY: ${{needs.prepare-env.outputs.ECR_REPOSITORY}} + IMAGE_TAG: ${{ github.event.inputs.tag }} + ECS_CLUSTER: ${{ needs.prepare-env.outputs.ECS_CLUSTER }} + ECS_SERVICE: ${{ needs.prepare-env.outputs.ECS_SERVICE }} + TASK_DEFINITION: ${{ needs.prepare-env.outputs.TASK_DEFINITION }} + CONTAINER_NAME: ${{ needs.prepare-env.outputs.CONTAINER_NAME }} + + steps: + - name: Checkout code from action + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets[env.AWS_ROLE] }} + aws-region: ${{ env.AWS_REGION }} + + - name: Amazon ECR Login + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1.7.0 + + - name: Check if image tag exists in ECR + id: check-image-existence + run: | + if aws ecr describe-images --repository-name "${{ env.ECR_REPOSITORY }}" --region "${{ env.AWS_REGION }}" --image-ids imageTag="${{ env.IMAGE_TAG }}" 2>&1 | grep -q "imageTag"; then + echo "Image tag $IMAGE_TAG exists in ECR" + else + echo "Error: Image tag $IMAGE_TAG does not exist in ECR" + exit 1 + fi + + - name: Deploy backend + id: deploy_backend + uses: ./.github/actions/deploy-ecs + env: + APP_IMAGE: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + with: + aws-region : ${{ env.AWS_REGION }} + aws-role: ${{ secrets[env.AWS_ROLE] }} + task-definition: ${{ env.TASK_DEFINITION }} + container-name: ${{ env.CONTAINER_NAME }} + ecs-service: ${{ env.ECS_SERVICE }} + ecs-cluster: ${{ env.ECS_CLUSTER }} + image: ${{ env.APP_IMAGE }} \ No newline at end of file diff --git a/.github/workflows/ci-server-.yaml b/.github/workflows/ci-server-.yaml new file mode 100644 index 0000000000..0fcb600762 --- /dev/null +++ b/.github/workflows/ci-server-.yaml @@ -0,0 +1,160 @@ +name: Build & Publish Conductor Server + +on: + workflow_dispatch: + inputs: + Environment: + required: true + type: choice + description: Choose aws env + options: + - dev + - stg + - prd + Tag: + required: true + type: string + description: Provide tag (Eg:v3.14.0) + +env: + SERVICE_NAME: conductor-server + AWS_REGION: "ap-south-1" + +jobs: + prepare-env: + name: Prepare Env + runs-on: 'ubuntu-latest' + timeout-minutes: 2 + outputs: + AWS_ROLE: ${{ steps.vars.outputs.AWS_ROLE }} + ENV: ${{ steps.vars.outputs.ENV }} + PROJECT_PREFIX: ${{ steps.vars.outputs.PROJECT_PREFIX }} + ECS_CLUSTER: ${{ steps.set_env.outputs.ECS_CLUSTER }} + ECR_REPOSITORY: ${{ steps.set_env.outputs.ECR_REPOSITORY }} + ENVIRONMENT_BUCKET: ${{ steps.set_env.outputs.ENVIRONMENT_BUCKET }} + SLACK_WEBHOOK_URL: ${{ steps.vars.outputs.SLACK_WEBHOOK_URL }} + + steps: + - id: vars + shell: bash + run: | + BRANCH="${GITHUB_REF#refs/heads/}" + ENV=${{ github.event.inputs.environment }} + IMAGE_TAG=${{ github.event.inputs.tag }} + echo $BRANCH + + if [ -z "$ENV" ] + then + case $BRANCH in + "dev") + ENV="dev" + ;; + "stg") + ENV="stg" + ;; + "main") + ENV="prd" + ;; + *) + echo "ENV not configured" && exit 1 + ;; + esac + fi + if [[ $ENV == 'prd' && $BRANCH == 'production' ]] + then + echo "AWS_ROLE=PRD_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-prd-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=PRD_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'stg' ] + then + echo "AWS_ROLE=STG_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-stg-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'dev' ] + then + echo "AWS_ROLE=DEV_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-dev-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + else + echo "Branch not configured!" + exit 1 + fi + echo "ENV=$ENV" >> $GITHUB_OUTPUT + echo ":rocket: Environment - $ENV " >> $GITHUB_STEP_SUMMARY + echo ":label: Image Tag - $IMAGE_TAG " >> $GITHUB_STEP_SUMMARY + - name: set variables + id: set_env + run: | + PROJECT_PREFIX=${{ steps.vars.outputs.PROJECT_PREFIX }} + echo "ECS_CLUSTER=$PROJECT_PREFIX-ecs-cluster" >> $GITHUB_OUTPUT + echo "ECR_REPOSITORY=$PROJECT_PREFIX-ecr-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "ENVIRONMENT_BUCKET=$PROJECT_PREFIX-s3-environment" >> $GITHUB_OUTPUT + echo ":seedling: Branch:${GITHUB_REF#refs/heads/}" >> $GITHUB_STEP_SUMMARY + + # Building and Pushing Conductor Server Image to ECR + build-push-image: + name: Build and Push Server Image + runs-on: 'ubuntu-latest' + timeout-minutes: 20 + permissions: + id-token: write + pull-requests: write + contents: read + needs: prepare-env + env: + AWS_ROLE: ${{ needs.prepare-env.outputs.AWS_ROLE }} + ENV: ${{ needs.prepare-env.outputs.ENV }} + PROJECT_PREFIX: ${{needs.prepare-env.outputs.PROJECT_PREFIX}} + ECR_REPOSITORY: ${{needs.prepare-env.outputs.ECR_REPOSITORY}} + ENVIRONMENT_BUCKET: ${{needs.prepare-env.outputs.ENVIRONMENT_BUCKET}} + IMAGE_TAG: ${{ github.event.inputs.tag }} + outputs: + ECR_REPO: ${{ steps.build.outputs.ECR_REPO }} + APP_IMAGE: ${{ steps.image.outputs.APP_IMAGE }} + + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + - + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets[env.AWS_ROLE] }} + aws-region: ${{ env.AWS_REGION }} + + - name: Download S3 file + run: | + aws s3 cp s3://${PROJECT_PREFIX}-s3-environment/conductor-server/conductor-server.properties ./docker/server/config/conductor-server.properties + + - name: Amazon ECR Login + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1.7.0 + + - name: Build and push to Amazon ECR + id: build + uses: docker/build-push-action@v5.1.0 + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + with: + context: . + file: ./Dockerfile + push: true + provenance: false + platforms: linux/amd64 + tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + + - name: Image name + id: image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + echo "APP_IMAGE=${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT + diff --git a/.github/workflows/ci-ui.yaml b/.github/workflows/ci-ui.yaml new file mode 100644 index 0000000000..00b58625b9 --- /dev/null +++ b/.github/workflows/ci-ui.yaml @@ -0,0 +1,174 @@ +name: Build & Publish Conductor UI + +on: + workflow_dispatch: + inputs: + Environment: + required: true + type: choice + description: Choose aws env + options: + - dev + - stg + - prd + Tag: + required: true + type: string + description: Provide tag (Eg:v3.14.0) + +env: + SERVICE_NAME: conductor-ui + AWS_REGION: "ap-south-1" + +jobs: + prepare-env: + name: Prepare Env + runs-on: 'ubuntu-latest' + timeout-minutes: 2 + outputs: + AWS_ROLE: ${{ steps.vars.outputs.AWS_ROLE }} + ENV: ${{ steps.vars.outputs.ENV }} + PROJECT_PREFIX: ${{ steps.vars.outputs.PROJECT_PREFIX }} + ECS_CLUSTER: ${{ steps.set_env.outputs.ECS_CLUSTER }} + ECR_REPOSITORY: ${{ steps.set_env.outputs.ECR_REPOSITORY }} + ENVIRONMENT_BUCKET: ${{ steps.set_env.outputs.ENVIRONMENT_BUCKET }} + DEFAULT_CONF: ${{ steps.vars.outputs.DEFAULT_CONF }} + SLACK_WEBHOOK_URL: ${{ steps.vars.outputs.SLACK_WEBHOOK_URL }} + + steps: + - id: vars + shell: bash + run: | + BRANCH="${GITHUB_REF#refs/heads/}" + ENV=${{ github.event.inputs.environment }} + IMAGE_TAG=${{ github.event.inputs.tag }} + echo $BRANCH + + if [ -z "$ENV" ] + then + case $BRANCH in + "dev") + ENV="dev" + ;; + "stg") + ENV="stg" + ;; + "main") + ENV="prd" + ;; + *) + echo "ENV not configured" && exit 1 + ;; + esac + fi + if [[ $ENV == 'prd' && $BRANCH == 'production' ]] + then + echo "AWS_ROLE=PRD_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-prd-mb" >> $GITHUB_OUTPUT + echo "DEFAULT_CONF=default-prd.conf" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=PRD_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'stg' ] + then + echo "AWS_ROLE=STG_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-stg-mb" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + elif [ $ENV == 'dev' ] + then + echo "AWS_ROLE=DEV_AWS_ROLE" >> $GITHUB_OUTPUT + echo "PROJECT_PREFIX=sirn-dev-mb" >> $GITHUB_OUTPUT + echo "DEFAULT_CONF=default-dev.conf" >> $GITHUB_OUTPUT + echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT + else + echo "Branch not configured!" + exit 1 + fi + echo "ENV=$ENV" >> $GITHUB_OUTPUT + echo ":rocket: Environment - $ENV " >> $GITHUB_STEP_SUMMARY + echo ":label: Image Tag - $IMAGE_TAG " >> $GITHUB_STEP_SUMMARY + - name: set variables + id: set_env + run: | + PROJECT_PREFIX=${{ steps.vars.outputs.PROJECT_PREFIX }} + echo "ECS_CLUSTER=$PROJECT_PREFIX-ecs-cluster" >> $GITHUB_OUTPUT + echo "ECR_REPOSITORY=$PROJECT_PREFIX-ecr-$SERVICE_NAME" >> $GITHUB_OUTPUT + echo "ENVIRONMENT_BUCKET=$PROJECT_PREFIX-s3-environment" >> $GITHUB_OUTPUT + echo ":seedling: Branch:${GITHUB_REF#refs/heads/}" >> $GITHUB_STEP_SUMMARY + + # Building and Pushing Conductor UI Image to ECR + build-push-ui-image: + name: Build and Push UI Image + runs-on: 'ubuntu-latest' + timeout-minutes: 20 + permissions: + id-token: write + pull-requests: write + contents: read + needs: prepare-env + env: + AWS_ROLE: ${{ needs.prepare-env.outputs.AWS_ROLE }} + ENV: ${{ needs.prepare-env.outputs.ENV }} + PROJECT_PREFIX: ${{needs.prepare-env.outputs.PROJECT_PREFIX}} + ECR_REPOSITORY: ${{needs.prepare-env.outputs.ECR_REPOSITORY}} + ENVIRONMENT_BUCKET: ${{needs.prepare-env.outputs.ENVIRONMENT_BUCKET}} + DEFAULT_CONF: ${{needs.prepare-env.outputs.DEFAULT_CONF}} + IMAGE_TAG: ${{ github.event.inputs.tag }} + outputs: + ECR_REPO: ${{ steps.build.outputs.ECR_REPO }} + APP_IMAGE: ${{ steps.image.outputs.APP_IMAGE }} + + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + - + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets[env.AWS_ROLE] }} + aws-region: ${{ env.AWS_REGION }} + + - name: Download S3 file + run: | + aws s3 cp s3://${PROJECT_PREFIX}-s3-environment/conductor-ui/.env ./ui/.env + + - name: Amazon ECR Login + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1.7.0 + + - name: Set Up Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Yarn Build + run: | + cd ui/ + mv ./${{ env.DEFAULT_CONF }} ./default.conf + yarn install && yarn build + + - name: Build and push to Amazon ECR + id: build + uses: docker/build-push-action@v5.1.0 + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + with: + context: ./ui/ + file: ./ui/Dockerfile + push: true + provenance: false + platforms: linux/amd64 + tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + + - name: Image name + id: image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + echo "APP_IMAGE=${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index a25c97dd2e..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: CI - -on: [ push, pull_request ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - name: Gradle wrapper validation - uses: gradle/wrapper-validation-action@v1 - - name: Set up Zulu JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Gradle packages - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: ${{ runner.os }}-gradle- - - name: Build with Gradle - if: github.ref != 'refs/heads/main' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - ./gradlew build --scan - - name: Build and Publish snapshot - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - run: | - echo "Running build for commit ${{ github.sha }}" - ./gradlew build - - name: Publish Test Report - uses: mikepenz/action-junit-report@v3 - if: always() - with: - report_paths: '**/build/test-results/test/TEST-*.xml' - - name: Upload build artifacts - uses: actions/upload-artifact@v3 - with: - name: build-artifacts - path: '**/build/reports' - - name: Store Buildscan URL - uses: actions/upload-artifact@v3 - with: - name: build-scan - path: 'buildscan.log' - build-ui: - runs-on: ubuntu-latest - container: cypress/browsers:node14.17.6-chrome100-ff98 - defaults: - run: - working-directory: ui - steps: - - uses: actions/checkout@v3 - - - name: Install Dependencies - run: yarn install - - - name: Build UI - run: yarn run build - - - name: Run E2E Tests - uses: cypress-io/github-action@v4 - with: - working-directory: ui - install: false - start: yarn run serve-build - wait-on: 'http://localhost:5000' - - - name: Run Component Tests - uses: cypress-io/github-action@v4 - with: - working-directory: ui - install: false - component: true - - - name: Archive test screenshots - uses: actions/upload-artifact@v2 - if: failure() - with: - name: cypress-screenshots - path: ui/cypress/screenshots - - - name: Archive test videos - uses: actions/upload-artifact@v2 - if: always() - with: - name: cypress-videos - path: ui/cypress/videos - diff --git a/.github/workflows/generate_gh_pages.yml b/.github/workflows/generate_gh_pages.yml deleted file mode 100644 index 8c429e1b8e..0000000000 --- a/.github/workflows/generate_gh_pages.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Publish docs via GitHub Pages -on: - workflow_dispatch - -jobs: - build: - name: Deploy docs - runs-on: ubuntu-latest - steps: - - name: Checkout main - uses: actions/checkout@v2 - - - name: Deploy docs - uses: mhausenblas/mkdocs-deploy-gh-pages@master - env: - GITHUB_TOKEN: ${{ secrets.DOCSITE_TOKEN }} - CONFIG_FILE: mkdocs.yml - REQUIREMENTS: requirements.txt diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 51b514ffa3..0000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Publish Conductor OSS toMaven Central -on: - release: - types: - - released - - prereleased - -permissions: - contents: read - -jobs: - publish: - runs-on: ubuntu-latest - name: Gradle Build and Publish - steps: - - uses: actions/checkout@v3 - - name: Set up Zulu JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - - name: Cache Gradle packages - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Publish release - run: | - export VERSION="${{github.ref_name}}" - export PUBLISH_VERSION=`echo ${VERSION:1}` - echo Publishing version $PUBLISH_VERSION - ./gradlew publish -Pversion=$PUBLISH_VERSION -Pusername=${{ secrets.SONATYPE_USERNAME }} -Ppassword=${{ secrets.SONATYPE_PASSWORD }} - env: - ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release_draft.yml b/.github/workflows/release_draft.yml deleted file mode 100644 index 2f185417d7..0000000000 --- a/.github/workflows/release_draft.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Release Drafter - -on: - push: - branches: - - main - -permissions: - contents: read - -jobs: - update_release_draft: - permissions: - contents: write # for release-drafter/release-drafter to create a github release - pull-requests: write # for release-drafter/release-drafter to add label to PR - runs-on: ubuntu-latest - steps: - - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}