Skip to content

Commit

Permalink
chore(CI): Separated deployment and docker build jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Jul 11, 2024
1 parent dbd5222 commit 090e193
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ on:
- main

jobs:
deploy-alpha:
build:
runs-on: ubuntu-latest
environment: alpha
name: Build and push API docker image for release
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout
Expand Down Expand Up @@ -40,6 +39,15 @@ jobs:
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6}
echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT
setup-database:
name: Setup Database
runs-on: ubuntu-latest
environment: alpha

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -56,6 +64,22 @@ jobs:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: pnpm db:deploy-migrations

deploy:
runs-on: ubuntu-latest
environment: alpha
name: Deploy API docker image for release

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.SECRET_KEY }}
aws-region: ap-south-1

- name: Force re-deploy task in service
id: force-redeploy
env:
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/deploy-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ on:
- main

jobs:
deploy-alpha:
build:
runs-on: ubuntu-latest
environment: alpha
name: Build and push Platform docker image for release
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout
Expand All @@ -34,12 +33,28 @@ jobs:
run: |
# Build a docker container and push it to ECR
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f ./apps/platform/Dockerfile .
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f ./apps/web/Dockerfile .
echo "Pushing image to ECR..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6}
echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-latest
environment: alpha
name: Deploy Platform docker image for release

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.SECRET_KEY }}
aws-region: ap-south-1

- name: Force re-deploy task in service
id: force-redeploy
env:
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ on:
- main

jobs:
deploy-alpha:
build:
runs-on: ubuntu-latest
environment: alpha
name: Build and push Web docker image for release
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout
Expand Down Expand Up @@ -40,6 +39,22 @@ jobs:
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6}
echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-latest
environment: alpha
name: Deploy Web docker image for release

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.SECRET_KEY }}
aws-region: ap-south-1

- name: Force re-deploy task in service
id: force-redeploy
env:
Expand Down

0 comments on commit 090e193

Please sign in to comment.