Skip to content

Database Migrations

Database Migrations #3

Workflow file for this run

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: Clone repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- 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'"