forked from amaldonado17/mundose-pin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73a4c6b
commit 516a987
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Terraform Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Terraform | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: 0.14.11 | ||
|
||
- name: Terraform Init | ||
run: terraform init | ||
|
||
- name: Terraform Apply | ||
run: terraform apply -auto-approve | ||
|
||
- name: Get public IP | ||
run: echo "Public IP: ${{ steps.set-outputs.outputs.public_ip }}" | ||
id: set-outputs | ||
env: | ||
TF_STATE: ${{ secrets.TF_STATE }} | ||
|
||
- name: Deploy to EC2 | ||
run: | | ||
PUBLIC_IP=$(terraform output -json public_ip | jq -r '.') | ||
echo "Deploying to EC2 at $PUBLIC_IP" | ||
# Puedes agregar comandos adicionales para el despliegue, como copiar archivos, etc. | ||
- name: Terraform Destroy (cleanup) | ||
if: always() | ||
run: terraform destroy -auto-approve |