Skip to content

Commit 6e02359

Browse files
fix: test env setup
1 parent 853c60a commit 6e02359

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

.github/workflows/terraform-deploy.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,20 @@ jobs:
3434
terraform init
3535
3636
- name: Terraform Apply
37+
id: terraform
3738
run: |
3839
cd infrastructure/terraform
3940
terraform apply -auto-approve
41+
echo "public_ip=$(terraform output -raw public_ip)" >> $GITHUB_OUTPUT
4042
env:
4143
TF_VAR_aws_access_key: ${{ github.event.inputs.aws_access_key_id }}
4244
TF_VAR_aws_secret_key: ${{ github.event.inputs.aws_secret_access_key }}
4345
TF_VAR_aws_session_token: ${{ github.event.inputs.aws_session_token }}
4446

45-
- name: Get EC2 Public IP
46-
id: get-ip
47-
run: |
48-
cd infrastructure/terraform
49-
echo "ip=$(terraform output -raw public_ip)" >> $GITHUB_OUTPUT
50-
5147
- name: Copy Docker Compose File From Repo to VM Host
5248
uses: appleboy/[email protected]
5349
with:
54-
host: ${{ steps.get-ip.outputs.ip }}
50+
host: ${{ steps.terraform.outputs.public_ip }}
5551
username: ubuntu
5652
key: ${{ secrets.AWS_EC2_PRIVATE_KEY }}
5753
source: "deployment/compose.aws.yml"
@@ -62,22 +58,22 @@ jobs:
6258
- name: SSH to VM and Create .env.prod
6359
uses: appleboy/[email protected]
6460
with:
65-
host: ${{ steps.get-ip.outputs.ip }}
61+
host: ${{ steps.terraform.outputs.public_ip }}
6662
username: ubuntu
6763
key: ${{ secrets.AWS_EC2_PRIVATE_KEY }}
6864
script: |
6965
cd /home/ubuntu
7066
rm -f .env.prod
7167
touch .env.prod
72-
echo "EC2_PUBLIC_IP=${{ steps.get-ip.outputs.ip }}" >> .env.prod
73-
echo "CLIENT_HOST=client.${{ steps.get-ip.outputs.ip }}.nip.io" >> .env.prod
74-
echo "SERVER_HOST=api.${{ steps.get-ip.outputs.ip }}.nip.io" >> .env.prod
75-
echo "PUBLIC_API_URL=https://api.${{ steps.get-ip.outputs.ip }}.nip.io" >> .env.prod
68+
echo "EC2_PUBLIC_IP=${{ steps.terraform.outputs.public_ip }}" >> .env.prod
69+
echo "CLIENT_HOST=client.${{ steps.terraform.outputs.public_ip }}.nip.io" >> .env.prod
70+
echo "SERVER_HOST=api.${{ steps.terraform.outputs.public_ip }}.nip.io" >> .env.prod
71+
echo "PUBLIC_API_URL=https://api.${{ steps.terraform.outputs.public_ip }}.nip.io" >> .env.prod
7672
7773
- name: SSH to VM and Execute Docker-Compose Up
7874
uses: appleboy/[email protected]
7975
with:
80-
host: ${{ steps.get-ip.outputs.ip }}
76+
host: ${{ steps.terraform.outputs.public_ip }}
8177
username: ubuntu
8278
key: ${{ secrets.AWS_EC2_PRIVATE_KEY }}
8379
script: |

0 commit comments

Comments
 (0)