From 134b132c07e6ca74a1908473273c0027187d224a Mon Sep 17 00:00:00 2001 From: Prakash Date: Wed, 5 Jun 2024 01:30:51 +0530 Subject: [PATCH] feat: add conditional environment for action --- .github/workflows/deploy-to-ec2.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-ec2.yml b/.github/workflows/deploy-to-ec2.yml index 4bbea2cd..c31820d5 100644 --- a/.github/workflows/deploy-to-ec2.yml +++ b/.github/workflows/deploy-to-ec2.yml @@ -3,6 +3,7 @@ name: Deploy to EC2 on: push: branches: + - main - develop - feat/aws-deploy # Remove before merting this PR to dev @@ -10,7 +11,7 @@ jobs: build-and-push: runs-on: ubuntu-latest timeout-minutes: 10 - environment: staging + environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'staging' }} steps: - name: Checkout Repository @@ -43,7 +44,7 @@ jobs: with: host: ${{ secrets.AWS_EC2_HOST }} username: ${{ secrets.AWS_EC2_USERNAME }} - key: ${{ secrets.AWS_EC2_SSH_PRIVATE_KEY }} + key: ${{ secrets.AWS_EC2_SSH_PRIVATE_KEY }} script: | docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest docker stop ${{ github.event.repository.name }}-${{ vars.ENV }} || true