Skip to content

Commit 3de59ce

Browse files
committed
logs in ecr
1 parent 47b9b84 commit 3de59ce

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

.github/workflows/deploy-to-ecr.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,49 @@ jobs:
4444
terraform apply -auto-approve -input=false -var="AWS_REGION=${{ env.AWS_REGION }}"
4545
working-directory: ./terraform
4646

47-
- name: Get ECR Repository URL
47+
# - name: Get ECR Repository URL
48+
# id: get_ecr_url
49+
# run: echo "ECR_REPOSITORY_URL=$(terraform output -raw ecr_repository_url)" >> $GITHUB_ENV
50+
# working-directory: ./terraform
51+
52+
- name: Get ECR Repository URL and Add Debug Logs
4853
id: get_ecr_url
49-
run: echo "ECR_REPOSITORY_URL=$(terraform output -raw ecr_repository_url)" >> $GITHUB_ENV
50-
working-directory: ./terraform
51-
# Esto hace que ECR_REPOSITORY_URL esté disponible como una variable de entorno (env.ECR_REPOSITORY_URL)
52-
# para los pasos siguientes.
54+
working-directory: ./terraform # Asegúrate de que esta es la ruta correcta a tu directorio de Terraform
55+
run: |
56+
echo "INFO: Current directory is $(pwd)"
57+
echo "INFO: Listing Terraform files in working directory:"
58+
ls -la
59+
60+
echo "INFO: Attempting to get ECR repository URL from Terraform output..."
61+
# Captura la salida en una variable para poder inspeccionarla y usarla
62+
TF_OUTPUT_ECR_URL=$(terraform output -raw ecr_repository_url)
63+
64+
echo "DEBUG: Raw output from 'terraform output -raw ecr_repository_url' is:"
65+
echo "--------------------------------------------------"
66+
echo "${TF_OUTPUT_ECR_URL}"
67+
echo "--------------------------------------------------"
68+
69+
# Verifica si la salida está vacía
70+
if [ -z "${TF_OUTPUT_ECR_URL}" ]; then
71+
echo "::error title=Terraform Output Empty::Terraform output for 'ecr_repository_url' was empty. Please check your Terraform configuration and ensure the output value 'ecr_repository_url' is correctly defined and populated after 'terraform apply'."
72+
# Opcionalmente, puedes hacer que el job falle si esto es crítico
73+
# exit 1
74+
fi
75+
76+
# Verifica si la salida contiene "***" lo cual indicaste como un problema
77+
if [[ "${TF_OUTPUT_ECR_URL}" == *"***"* ]]; then
78+
echo "::warning title=Problematic ECR URL::The ECR Repository URL from Terraform output contains '***'. This usually indicates an issue with region resolution or configuration within your Terraform code."
79+
echo "Problematic URL: ${TF_OUTPUT_ECR_URL}"
80+
else
81+
echo "INFO: The ECR Repository URL obtained seems structurally valid (does not contain '***')."
82+
fi
83+
84+
echo "INFO: Setting GITHUB_ENV variable ECR_REPOSITORY_URL..."
85+
echo "ECR_REPOSITORY_URL=${TF_OUTPUT_ECR_URL}" >> $GITHUB_ENV
86+
echo "INFO: ECR_REPOSITORY_URL has been set in GITHUB_ENV."
87+
88+
# Para verificar que se estableció correctamente en GITHUB_ENV (opcional, ya que el siguiente paso lo usará)
89+
# echo "Checking env.ECR_REPOSITORY_URL (simulated for next step): $ECR_REPOSITORY_URL"
5390
5491
- name: Login to Amazon ECR
5592
id: login-ecr

0 commit comments

Comments
 (0)