1
+ ---
2
+ - hosts : elevate
3
+ vars :
4
+ project_path : /opt/frontend/elevate-project-pwa
5
+ root_path : /opt/frontend
6
+ tasks :
7
+ - name : Slurp host file
8
+ slurp :
9
+ src : " /opt/backend/deployment/.token"
10
+ register : slurpfile
11
+ - name : Run vault credentials
12
+ shell : " curl --location --request GET '{{ vaultAddress }}elevate-project-pws' --header 'X-Vault-Token: {{ slurpfile['content'] | b64decode }}' | jq '.data' > '{{root_path}}/data2.json'"
13
+ register : vaultCurl
14
+ - name : Change directory
15
+ shell : cd {{project_path}}
16
+ - name : Fetch the latest code
17
+ git :
18
+ repo : https://github.com/ELEVATE-Project/observation-survey-projects-pwa
19
+ dest : " {{project_path}}"
20
+ version : " {{gitBranch}}"
21
+ force : yes
22
+ - name : Update npm
23
+ shell : cd {{project_path}} && npm i --force
24
+ - name : Set permission
25
+ shell : chmod 744 {{ project_path }}/src/scripts/json2env.sh
26
+ - name : Generate .env
27
+ shell : cat {{root_path}}/data2.json | jq '.data' > {{ project_path }}/src/environments/environment.ts && sed -i '1s/^/export const environment = \n/' {{ project_path }}/src/environments/environment.ts
28
+ register : envConfig
29
+ - debug : msg=" cred {{ envConfig }} "
30
+ - name : Change directory
31
+ shell : chdir {{project_path}}
32
+ - name : Fetch pm2 config file
33
+ shell : " curl --location --request GET '{{ vaultAddress }}projetcsPWAPm2Config' --header 'X-Vault-Token: {{ slurpfile['content'] | b64decode }}' | jq '.data.data' > '{{ project_path }}/pm2.config.json'"
34
+ register : pm2
35
+ - name : Change directory
36
+ shell : cd {{project_path}}
37
+ - name : Remove www folder
38
+ shell : rm -rf www
39
+ - name : Build pwa app
40
+ shell : cd {{project_path}} && ionic build --prod
41
+ - name : Start pm2
42
+ shell : cd {{project_path}} && pm2 start pm2.config.json
0 commit comments