Skip to content

Commit bb4635f

Browse files
committed
fixed extraction errors
1 parent 2ef04cc commit bb4635f

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

.github/workflows/terraform.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ jobs:
115115
with:
116116
name: inventory
117117
path: ansible/inventory.ini
118+
- name: Upload terraform.tfvars
119+
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: terraform-vars
123+
path: infra/terraform.tfvars
124+
retention-days: 1
118125

119126
- name: 🗃️ Run Script Configure Jumpbox
120127
run: |
@@ -201,28 +208,26 @@ jobs:
201208
run: |
202209
cd infra
203210
204-
# Get outputs using raw text format (not JSON)
205-
APP_NAME=$(terraform output -raw app_service_name)
206-
RG_NAME=$(terraform output -raw resource_group_name)
207-
API_URL=$(terraform output -raw lb_api_url)
211+
# Get outputs using separate commands with proper sanitization
212+
APP_NAME=$(terraform output app_service_name | sed 's/"//g' | tr -d '\n')
213+
RG_NAME=$(terraform output resource_group_name | sed 's/"//g' | tr -d '\n')
214+
API_URL=$(terraform output lb_api_url | sed 's/"//g' | tr -d '\n')
208215
209-
# Verify outputs are not empty
210-
if [[ -z "$APP_NAME" || -z "$RG_NAME" || -z "$API_URL" ]]; then
211-
echo "::error::Missing required Terraform outputs"
212-
terraform output
216+
# Verify outputs don't contain command strings
217+
if [[ "$APP_NAME" == *"command"* || "$RG_NAME" == *"command"* || "$API_URL" == *"command"* ]]; then
218+
echo "::error::Terraform outputs contain command strings!"
219+
echo "APP_NAME: $APP_NAME"
220+
echo "RG_NAME: $RG_NAME"
221+
echo "API_URL: $API_URL"
213222
exit 1
214223
fi
215224
216-
# Sanitize outputs (remove any special characters)
217-
APP_NAME=$(echo "$APP_NAME" | tr -d '\n\r"')
218-
RG_NAME=$(echo "$RG_NAME" | tr -d '\n\r"')
219-
API_URL=$(echo "$API_URL" | tr -d '\n\r"')
220-
221-
echo "webapp_name=${APP_NAME}" >> $GITHUB_OUTPUT
222-
echo "resource_group=${RG_NAME}" >> $GITHUB_OUTPUT
223-
echo "api_url=${API_URL}" >> $GITHUB_OUTPUT
225+
# Set outputs
226+
echo "app_service_name=${APP_NAME}" >> $GITHUB_OUTPUT
227+
echo "resource_group_name=${RG_NAME}" >> $GITHUB_OUTPUT
228+
echo "lb_api_url=${API_URL}" >> $GITHUB_OUTPUT
224229
225-
echo "✅ Verified outputs:"
230+
echo "✅ Verified clean outputs:"
226231
echo "APP: ${APP_NAME}"
227232
echo "RG: ${RG_NAME}"
228233
echo "API: ${API_URL}"

ansible/deploy-frontend.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
node_version: "16-lts"
77

88
tasks:
9-
- name: Validate required variables
10-
assert:
11-
that:
12-
- app_service_name is defined
13-
- resource_group_name is defined
14-
- lb_api_url is defined
15-
fail_msg: "Missing required variables from GitHub Actions"
16-
success_msg: "All required variables present"
9+
- name: Validate variables don't contain command strings
10+
fail:
11+
msg: |
12+
Invalid variables detected!
13+
- App Service: {{ app_service_name }}
14+
- Resource Group: {{ resource_group_name }}
15+
- API URL: {{ lb_api_url }}
16+
Check GitHub Actions workflow for proper output handling.
17+
when: >
18+
'[command]' in app_service_name or
19+
'[command]' in resource_group_name or
20+
'[command]' in lb_api_url
1721
1822
- name: Show deployment configuration
1923
debug:

0 commit comments

Comments
 (0)