From 8e9dc74a75f9f50d8e5c14b47810f0155f0fb014 Mon Sep 17 00:00:00 2001 From: can kurttekin Date: Tue, 19 Nov 2024 09:43:13 +0300 Subject: [PATCH] syntax fix --- .github/workflows/deploy.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 385ec32c..a65b4d9f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,21 +17,19 @@ jobs: # Set up SSH Key for EC2 Access - name: Set Up SSH env: - EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }} + PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }} + EC2_USER: ${{ secrets.EC2_USER }} + EC2_HOST: ${{ secrets.EC2_HOST }} run: | - mkdir -p ~/.ssh - echo "$EC2_SSH_KEY" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa + echo "$PRIVATE_KEY" > github-ec2 && chmod 600 github-ec2 # Copy backend files to EC2 - name: Deploy Application to EC2 env: - EC2_USER: ${{ secrets.EC2_USER }} - EC2_HOST: ${{ secrets.EC2_HOST }} run: | echo "Copying backend directory to EC2..." - ssh -v -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa $EC2_USER@$EC2_HOST "echo Connected" - scp -o StrictHostKeyChecking=no -r backend/docker-compose.yml $EC2_USER@$EC2_HOST:~/job-application-tracker/ + ssh -v -o StrictHostKeyChecking=no -i github-ec2 ${EC2_USER}@${EC2_HOST} "echo Connected" + scp -o StrictHostKeyChecking=no -r backend/docker-compose.yml ${EC2_USER}@${EC2_HOST}:~/job-application-tracker/ # Create .env file on EC2 - name: Configure Environment Variables @@ -51,7 +49,7 @@ jobs: TURNSTILE_SECRET: ${{ secrets.TURNSTILE_SECRET }} run: | echo "Creating .env file on EC2..." - ssh -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST << 'EOF' + ssh -o StrictHostKeyChecking=no ${EC2_USER}@${EC2_HOST} << 'EOF' mkdir -p ~/job-application-tracker cat < ~/job-application-tracker/.env APP_URL=${APP_URL} @@ -82,7 +80,7 @@ jobs: EC2_HOST: ${{ secrets.EC2_HOST }} run: | echo "Deploying application on EC2..." - ssh -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST << 'EOF' + ssh -o StrictHostKeyChecking=no ${EC2_USER}@${EC2_HOST} << 'EOF' cd ~/job-application-tracker docker-compose down docker-compose up --build -d