From 9dae612d3159c677264fe9a3243ea03eaf435a1f Mon Sep 17 00:00:00 2001 From: Navaneeth <107757582+navaneethkrishna30@users.noreply.github.com.> Date: Tue, 15 Oct 2024 19:04:31 +0530 Subject: [PATCH] ssh take3 --- .github/workflows/ci-cd.yaml | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 388d384..710d975 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -16,19 +16,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.12' - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - - name: Lint Code - run: pylint app.py || true - - name: Login to Amazon ECR uses: aws-actions/amazon-ecr-login@v2 env: @@ -63,15 +50,11 @@ jobs: - name: Deploy via SSH run: | - ssh -o StrictHostKeyChecking=no -i ec2_key.pem ec2-user@${{ secrets.EC2_INSTANCE_IP }}" - - export BACKEND_ECR=${{ secrets.BACKEND_ECR }}; - export FRONTEND_ECR=${{ secrets.FRONTEND_ECR }}; - export IMAGE_TAG=${{ github.sha }}; - - docker-compose pull; - docker-compose up -d" - env: - BACKEND_ECR: ${{ secrets.BACKEND_ECR }} - FRONTEND_ECR: ${{ secrets.FRONTEND_ECR }} - IMAGE_TAG: ${{ github.sha }} + echo "${{ secrets.EC2_SSH_KEY }}" > ec2_key.pem + chmod 600 ec2_key.pem + ssh -o StrictHostKeyChecking=no -i ec2_key.pem ec2-user@${{ secrets.EC2_INSTANCE_IP }} \ + "export BACKEND_ECR=${{ secrets.BACKEND_ECR }} && \ + export FRONTEND_ECR=${{ secrets.FRONTEND_ECR }} && \ + export IMAGE_TAG=${{ github.sha }} && \ + docker-compose pull && \ + docker-compose up -d"