Skip to content

Commit eea99c2

Browse files
committed
Fixed origin path
1 parent 778e65c commit eea99c2

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

ansible/deploy-frontend.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,49 @@
22
- name: Deploy frontend to Azure Web App
33
hosts: localhost
44
connection: local
5-
gather_facts: no
65
vars:
7-
resource_group: softdevrg
8-
app_name: softdefault-movies-app
9-
frontend_path: /home/adminuser/frontend
10-
zip_path: /tmp/frontend.zip
6+
APP_SERVICE_NAME: "{{ lookup('env', 'APP_SERVICE_NAME') }}"
7+
RESOURCE_GROUP_NAME: "{{ lookup('env', 'RESOURCE_GROUP_NAME') }}"
8+
FRONTEND_PATH: "../src/movie-analyst-ui"
9+
ZIP_PATH: "/tmp/frontend.zip"
10+
BACKEND_URL: "{{ lookup('env', 'LB_API_URL') }}"
1111

1212
tasks:
13+
14+
- name: Ensure frontend path exists
15+
stat:
16+
path: "{{ FRONTEND_PATH }}"
17+
register: frontend_dir
18+
19+
- name: Fail if frontend path does not exist
20+
fail:
21+
msg: "The frontend path '{{ FRONTEND_PATH }}' does not exist."
22+
when: not frontend_dir.stat.exists
23+
24+
- name: Create zip package (exclude node_modules and build artifacts)
25+
command: >
26+
zip -r {{ ZIP_PATH }} . -x "node_modules/*" -x ".next/*" -x "dist/*"
27+
args:
28+
chdir: "{{ FRONTEND_PATH }}"
29+
1330
- name: Enable Oryx build (SCM_DO_BUILD_DURING_DEPLOYMENT=true)
1431
shell: |
1532
az webapp config appsettings set \
16-
--resource-group {{ resource_group }} \
17-
--name {{ app_name }} \
33+
--resource-group {{ RESOURCE_GROUP_NAME }} \
34+
--name {{ APP_SERVICE_NAME }} \
1835
--settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
1936
20-
- name: Create zip package (exclude node_modules and build artifacts)
37+
- name: Set backend API URL as environment variable
2138
shell: |
22-
zip -r {{ zip_path }} . -x "node_modules/*" -x ".next/*" -x "dist/*"
23-
args:
24-
chdir: "{{ frontend_path }}"
39+
az webapp config appsettings set \
40+
--resource-group {{ RESOURCE_GROUP_NAME }} \
41+
--name {{ APP_SERVICE_NAME }} \
42+
--settings NEXT_PUBLIC_BACKEND_URL={{ BACKEND_URL }}
2543
2644
- name: Deploy zip to Azure Web App
2745
shell: |
2846
az webapp deploy \
29-
--resource-group {{ resource_group }} \
30-
--name {{ app_name }} \
31-
--src-path {{ zip_path }} \
47+
--resource-group {{ RESOURCE_GROUP_NAME }} \
48+
--name {{ APP_SERVICE_NAME }} \
49+
--src-path {{ ZIP_PATH }} \
3250
--type zip
33-
34-
- name: Show success message
35-
debug:
36-
msg: "✅ Successfully deployed to https://{{ APP_SERVICE_NAME }}.azurewebsites.net"

0 commit comments

Comments
 (0)