Skip to content

Commit b0383e1

Browse files
committed
updated strict validation
1 parent 669a26d commit b0383e1

File tree

2 files changed

+33
-51
lines changed

2 files changed

+33
-51
lines changed

.github/workflows/terraform.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,13 @@ jobs:
200200
id: tf
201201
run: |
202202
cd infra
203-
# Get raw outputs first
204-
APP_NAME=$(terraform output app_service_name)
205-
RG_NAME=$(terraform output resource_group_name)
206-
API_URL=$(terraform output lb_api_url)
203+
# Get all outputs as JSON
204+
terraform output -json > outputs.json
207205
208-
# Extract just the values (remove Terraform formatting)
209-
APP_NAME=$(echo "$APP_NAME" | sed 's/.*= "\(.*\)"/\1/' | tr -d '\n" ')
210-
RG_NAME=$(echo "$RG_NAME" | sed 's/.*= "\(.*\)"/\1/' | tr -d '\n" ')
211-
API_URL=$(echo "$API_URL" | sed 's/.*= "\(.*\)"/\1/' | tr -d '\n" ')
206+
# Parse JSON and set outputs
207+
APP_NAME=$(jq -r '.app_service_name.value' outputs.json)
208+
RG_NAME=$(jq -r '.resource_group_name.value' outputs.json)
209+
API_URL=$(jq -r '.lb_api_url.value' outputs.json)
212210
213211
echo "webapp_name=${APP_NAME}" >> $GITHUB_OUTPUT
214212
echo "resource_group=${RG_NAME}" >> $GITHUB_OUTPUT

ansible/deploy-frontend.yml

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,36 @@
33
hosts: localhost
44
connection: local
55
vars:
6-
frontend_src: "{{ frontend_src_dir | default('src/movie-analyst-ui') }}"
6+
app_service_name: ""
7+
resource_group_name: ""
8+
lb_api_url: ""
79
node_version: "16-lts"
8-
10+
911
tasks:
10-
# --- Debug variables first ---
11-
- name: Verify Azure resource variables
12-
debug:
12+
- name: Validate variables
13+
fail:
1314
msg: |
14-
RESOURCE_GROUP: {{ resource_group_name }}
15-
APP_NAME: {{ app_service_name }}
16-
BACKEND_URL: {{ lb_api_url }}
17-
18-
# --- Build steps ---
19-
- name: Install dependencies
20-
command: npm install
21-
args:
22-
chdir: "{{ frontend_src }}"
23-
24-
- name: Zip frontend application
25-
archive:
26-
path: "{{ frontend_src }}/"
27-
dest: "./frontend-deploy.zip"
28-
format: zip
29-
exclude_path:
30-
- "node_modules/.cache/"
31-
- "test/"
32-
- ".git/"
33-
34-
# --- Azure Deployment with API Version Fix ---
35-
- name: Get latest supported API version
36-
command: >
37-
az provider show --namespace Microsoft.Web
38-
--query "resourceTypes[?resourceType=='sites'].apiVersions[0]"
39-
--output tsv
40-
register: api_version_check
41-
changed_when: false
42-
ignore_errors: yes
15+
Invalid variables detected!
16+
- App Service: {{ app_service_name }}
17+
- Resource Group: {{ resource_group_name }}
18+
- API URL: {{ lb_api_url }}
19+
Check GitHub Actions workflow for proper output handling.
20+
when: >
21+
not app_service_name or
22+
not resource_group_name or
23+
not lb_api_url or
24+
'[' in app_service_name or
25+
'[' in resource_group_name or
26+
'[' in lb_api_url
4327
44-
- name: Set actual API version
45-
set_fact:
46-
azure_api_version: >-
47-
{% if api_version_check is succeeded %}
48-
{{ api_version_check.stdout }}
49-
{% else %}
50-
2024-11-01 # Fallback version
51-
{% endif %}
28+
- name: Show deployment configuration
29+
debug:
30+
msg: |
31+
Deployment Configuration:
32+
- App Service: {{ app_service_name }}
33+
- Resource Group: {{ resource_group_name }}
34+
- API URL: {{ lb_api_url }}
35+
- Node Version: {{ node_version }}
5236
5337
- name: Update Node.js runtime
5438
command: >
@@ -58,7 +42,7 @@
5842
--linux-fx-version "NODE|{{ node_version }}"
5943
--output none
6044
environment:
61-
AZURE_CLI_DEFAULT_API_VERSION: "{{ azure_api_version }}"
45+
AZURE_CLI_DEFAULT_API_VERSION: "2025-04-01"
6246

6347
- name: Set app settings
6448
command: >

0 commit comments

Comments
 (0)