From a942ececfd97a8be6d1c0e945e2775f0d26b8af9 Mon Sep 17 00:00:00 2001
From: Mohamed ER-Radi <erradi1994mohamed@gmail.com>
Date: Mon, 19 Feb 2024 18:12:00 +0100
Subject: [PATCH] fix ec2 server ip error

---
 .github/workflows/terraform-staging.yml | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/terraform-staging.yml b/.github/workflows/terraform-staging.yml
index 8e690cf72..e46ca06cd 100644
--- a/.github/workflows/terraform-staging.yml
+++ b/.github/workflows/terraform-staging.yml
@@ -47,13 +47,13 @@ jobs:
         if: success()
 
       - name: Extract Public IP
-        id: server_public_ip
-        run: echo "::set-output name=server_public_ip::$(cd terraform; terraform output server_public_ip)"
+        id: get_server_ip
+        run: echo "::set-output name=server_public_ip::$(cd terraform; terraform output -raw server_public_ip)"
         if: success()
 
       - name: Create .env file
         env:
-          HOST_URL: ${{ steps.server_public_ip.outputs.server_public_ip }}
+          HOST_URL: ${{ steps.get_server_ip.outputs.server_public_ip }}
           PLM_CLIENT_ID: ${{ secrets.STAGING_CLIENT_ID }}
         run: |
           cat << EOF > .env
@@ -77,9 +77,9 @@ jobs:
       - name: Transfer Docker Image to EC2
         run: |
           docker save -o 1village-image.tar 1village
-          scp -o StrictHostKeyChecking=no 1village-image.tar ec2-user@$server:~
-          ssh -o StrictHostKeyChecking=no ec2-user@$server 'cd ~ && docker load -i 1village-image.tar && docker-compose up -d'
+          scp -o StrictHostKeyChecking=no 1village-image.tar ec2-user@${{ steps.get_server_ip.outputs.server_public_ip }}:~
+          ssh -o StrictHostKeyChecking=no ec2-user@${{ steps.get_server_ip.outputs.server_public_ip }} 'cd ~ && docker load -i 1village-image.tar && docker-compose up -d'
         shell: bash
-        env:
-          server: ${{steps.server_public_ip.outputs.server_public_ip}}
+        #env:
+        #  server: ${{ steps.get_server_ip.outputs.server_public_ip }}
         if: success()