diff --git a/.github/workflows/deploy-api.yml b/.github/workflows/deploy-api.yml index 0271908fc..280e8c8c1 100644 --- a/.github/workflows/deploy-api.yml +++ b/.github/workflows/deploy-api.yml @@ -5,42 +5,38 @@ on: push: branches: - main + - develop paths: ['apps/api/**', '.github/workflows/deploy-api.yml', 'package.json'] jobs: build: runs-on: ubuntu-latest - environment: alpha + environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }} name: Build and push 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: Login to Amazon ECR - # id: login-ecr - # uses: aws-actions/amazon-ecr-login@v2 + - name: Docker Login + uses: azure/docker-login@v2 + with: + login-server: ${{ vars.ACR_REGISTRY_URL }} + username: ${{ secrets.ACR_USERNAME }} + password: ${{ secrets.ACR_PASSWORD }} - # - name: Build Docker image - # id: build - # env: - # ECR_REGISTRY: ${{ vars.ECR_REGISTRY }} - # ECR_REPOSITORY: ${{ vars.ECR_API_REPOSITORY }} - # 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/api/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 + - name: Build Docker image + id: build + env: + ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }} + REPOSITORY_NAME: api + run: | + # Build a docker container and push it to ACR + docker build -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest -f ./apps/web/Dockerfile . + echo "Pushing image to ACR..." + docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest + docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} + echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT # setup-database: # needs: build diff --git a/.github/workflows/deploy-platform.yml b/.github/workflows/deploy-platform.yml index 8ac2eeb59..53d98b55f 100644 --- a/.github/workflows/deploy-platform.yml +++ b/.github/workflows/deploy-platform.yml @@ -5,6 +5,7 @@ on: push: branches: - main + - develop paths: [ 'apps/platform/**', @@ -15,37 +16,32 @@ on: jobs: build: runs-on: ubuntu-latest - environment: alpha + environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }} name: Build and push 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: Login to Amazon ECR - # id: login-ecr - # uses: aws-actions/amazon-ecr-login@v2 + - name: Docker Login + uses: azure/docker-login@v2 + with: + login-server: ${{ vars.ACR_REGISTRY_URL }} + username: ${{ secrets.ACR_USERNAME }} + password: ${{ secrets.ACR_PASSWORD }} - # - name: Build Docker image - # id: build - # env: - # ECR_REGISTRY: ${{ vars.ECR_REGISTRY }} - # ECR_REPOSITORY: ${{ vars.ECR_PLATFORM_REPOSITORY }} - # 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 . - # 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 + - name: Build Docker image + id: build + env: + ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }} + REPOSITORY_NAME: platform + run: | + # Build a docker container and push it to ACR + docker build -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest -f ./apps/platform/Dockerfile . + echo "Pushing image to ACR..." + docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest + docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} + echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT # deploy: # needs: build