Skip to content

Commit

Permalink
Separate pipeline for UI & Server
Browse files Browse the repository at this point in the history
  • Loading branch information
infinyte-ops committed Jan 31, 2024
1 parent 2d973e0 commit 45801c4
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 70 deletions.
153 changes: 153 additions & 0 deletions .github/workflows/workflow-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Build & Publish OSS Conductor Server

on:
workflow_dispatch:
inputs:
Environment:
required: true
type: choice
description: Choose aws env
options:
- dev
- prd
Tag:
required: true
type: string
description: Provide tag (Eg:v3.14.0)

env:
SERVICE_NAME: conductor
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 }}
ECR_REPOSITORY_UI: ${{ steps.set_env.outputs.ECR_REPOSITORY_UI }}
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 }}
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 == '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
- 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-conductor-server" >> $GITHUB_OUTPUT
echo "ECR_REPOSITORY_UI=$PROJECT_PREFIX-conductor-ui" >> $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/[email protected]

- name: Build and push to Amazon ECR
id: build
uses: docker/[email protected]
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
context: .
file: ./Dockerfile
push: true
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build & Publish OSS Conductor
name: Build & Publish OSS Conductor UI

on:
workflow_dispatch:
Expand Down Expand Up @@ -32,6 +32,7 @@ jobs:
ECR_REPOSITORY: ${{ steps.set_env.outputs.ECR_REPOSITORY }}
ECR_REPOSITORY_UI: ${{ steps.set_env.outputs.ECR_REPOSITORY_UI }}
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:
Expand Down Expand Up @@ -63,11 +64,13 @@ jobs:
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 == '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!"
Expand All @@ -84,72 +87,6 @@ jobs:
echo "ECR_REPOSITORY_UI=$PROJECT_PREFIX-conductor-ui" >> $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/[email protected]

- name: Build and push to Amazon ECR
id: build
uses: docker/[email protected]
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
context: .
file: ./Dockerfile
push: true
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
# Building and Pushing Conductor UI Image to ECR
build-push-ui-image:
Expand All @@ -167,6 +104,7 @@ jobs:
PROJECT_PREFIX: ${{needs.prepare-env.outputs.PROJECT_PREFIX}}
ECR_REPOSITORY: ${{needs.prepare-env.outputs.ECR_REPOSITORY_UI}}
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 }}
Expand Down Expand Up @@ -198,15 +136,15 @@ jobs:
id: login-ecr
uses: aws-actions/[email protected]

- name: Node 18
- name: Setup 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
Expand All @@ -215,7 +153,7 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
context: .
context: ./ui/
file: ./ui/Dockerfile
push: true
platforms: linux/amd64
Expand Down

0 comments on commit 45801c4

Please sign in to comment.