Skip to content

Commit

Permalink
feat: add ci for database migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
nischalstha9 committed Jul 4, 2024
1 parent 804f325 commit 29a23c8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy_DTM_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: ${{ github.ref_name }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Database Migrations

on:
workflow_dispatch:

permissions:
id-token: write
contents: read

env:
AWS_REGION: ap-south-1
ECR_REGISTRY: 685797548389.dkr.ecr.ap-south-1.amazonaws.com
ECR_REPOSITORY: dtmweb

jobs:
migration:
name: Do migration on RDS
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
aws-region: ${{ env.AWS_REGION }}
role-session-name: GH-Actions-${{ github.run_id }}-${{ github.run_attempt }}
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }}

- name: Run migration command
id: run-migration
shell: bash
run: |
TASK_ID=`aws ecs list-tasks --cluster ${{ secrets.ECS_CLUSTER_NAME }} --service ${{ secrets.ECS_SERVICE_NAME }} | jq -r .taskArns[0]`
aws ecs execute-command --cluster dtm-ecs-cluster --task $TASK_ID --region ${{env.AWS_REGION}} --interactive --command "/bin/bash -c 'pdm run alembic upgrade head'"
2 changes: 1 addition & 1 deletion .github/workflows/test_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: ${{ github.ref_name }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

Expand Down

0 comments on commit 29a23c8

Please sign in to comment.