main.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. - name: Create build folder
  2. ansible.builtin.file:
  3. path: "{{ app_workspace | dirname }}"
  4. state: directory
  5. # owner: "{{ ansible_user }}"
  6. mode: "0755"
  7. - name: Git checkout mint repo
  8. ansible.builtin.git:
  9. repo: "https://github.com/iapt-platform/mint.git"
  10. dest: "{{ app_workspace }}"
  11. version: "{{ mint_version }}"
  12. - name: Extract dashboard-v4
  13. ansible.builtin.unarchive:
  14. src: dashboard-v4-{{ ansible_facts['architecture'] }}-20260116065749.tar.xz
  15. dest: "{{ app_workspace }}/dashboard-v4/dashboard"
  16. creates: "{{ app_workspace }}/dashboard-v4/dashboard/yarn.lock"
  17. - name: Extract api-v8
  18. ansible.builtin.unarchive:
  19. src: api-v8-20260117.tar.xz
  20. dest: "{{ app_workspace }}/api-v8"
  21. creates: "{{ app_workspace }}/api-v8/composer.lock"
  22. - name: Extract dashboard-v6
  23. ansible.builtin.unarchive:
  24. src: dashboard-v6-{{ ansible_facts['architecture'] }}-20260116064312.tar.xz
  25. dest: "{{ app_workspace }}/dashboard-v6"
  26. creates: "{{ app_workspace }}/dashboard-v6/package-lock.json"
  27. - name: Extract api-v12
  28. ansible.builtin.unarchive:
  29. src: api-v12-{{ ansible_facts['architecture'] }}-20260116064312.tar.xz
  30. dest: "{{ app_workspace }}/api-v12"
  31. creates: "{{ app_workspace }}/api-v12/composer.lock"
  32. - name: Extract open-ai-server
  33. ansible.builtin.unarchive:
  34. src: open-ai-server-{{ ansible_facts['architecture'] }}-20260116064312.tar.xz
  35. dest: "{{ app_workspace }}/open-ai-server"
  36. creates: "{{ app_workspace }}/open-ai-server/package-lock.json"
  37. - name: Build dashboard-v4
  38. ansible.builtin.shell: |
  39. source ~/.nvm/nvm.sh && yarn build
  40. args:
  41. executable: /bin/bash
  42. chdir: "{{ app_workspace }}/dashboard-v4/dashboard"
  43. creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v4"
  44. environment:
  45. BUILD_PATH: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v4"
  46. NODE_OPTIONS: "--max_old_space_size=5120"
  47. PUBLIC_URL: "{{ app_dashboard_v4_base_path }}"
  48. REACT_APP_DEFAULT_LOCALE: "zh-Hans"
  49. REACT_APP_LANGUAGES: "en-US,zh-Hans,zh-Hant"
  50. REACT_APP_ENABLE_LOCAL_TOKEN: "true"
  51. REACT_APP_TOKEN_KEY: "{{ app_dashboard_token_key }}"
  52. REACT_APP_DOCUMENTS_SERVER: "{{ app_documents_server }}"
  53. REACT_APP_RPC_SERVER: "{{ app_grpc_web_server }}"
  54. REACT_APP_ASSETS_SERVER: "{{ app_assets_server }}"
  55. REACT_APP_API_SERVER: "https://{{ app_domain }}"
  56. REACT_APP_ICP_CODE: "{{ app_icp_code }}"
  57. REACT_APP_MPS_CODE: "{{ app_mps_code }}"
  58. REACT_APP_QUESTIONNAIRE_LINK: "{{ app_questionnaire_link }}"
  59. REACT_APP_OPENAI_PROXY: "{{ app_openai_proxy_server }}/api/openai"
  60. - name: Build dashboard-v6
  61. ansible.builtin.shell: |
  62. source ~/.nvm/nvm.sh && npm run build -- --base={{ app_dashboard_v6_base_path }} --outDir {{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v6
  63. args:
  64. executable: /bin/bash
  65. chdir: "{{ app_workspace }}/dashboard-v6"
  66. creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/dashboard-v6"
  67. environment:
  68. NODE_ENV: production
  69. VITE_DEFAULT_LOCALE: "zh-Hans"
  70. VITE_LANGUAGES: "en-US,zh-Hans,zh-Hant"
  71. VITE_ENABLE_LOCAL_TOKEN: "true"
  72. VITE_TOKEN_KEY: "{{ app_dashboard_token_key }}"
  73. VITE_DOCUMENTS_SERVER: "{{ app_documents_server }}"
  74. VITE_RPC_SERVER: "{{ app_grpc_web_server }}"
  75. VITE_ASSETS_SERVER: "{{ app_assets_server }}"
  76. VITE_API_SERVER: "https://{{ app_domain }}"
  77. VITE_ICP_CODE: "{{ app_icp_code }}"
  78. VITE_MPS_CODE: "{{ app_mps_code }}"
  79. VITE_QUESTIONNAIRE_LINK: "{{ app_questionnaire_link }}"
  80. VITE_OPENAI_PROXY: "{{ app_openai_proxy_server }}/api/openai"
  81. - name: Build open-ai proxy server
  82. ansible.builtin.shell: |
  83. source ~/.nvm/nvm.sh && npm run build -- --output-path {{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/open-ai-server
  84. args:
  85. executable: /bin/bash
  86. chdir: "{{ app_workspace }}/open-ai-server"
  87. creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/open-ai-server"
  88. environment:
  89. NODE_ENV: production
  90. - name: Copy api-v8 to release folder
  91. ansible.posix.synchronize:
  92. src: "{{ app_workspace }}/api-v8"
  93. dest: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}"
  94. recursive: true
  95. - name: Copy api-v12 to release folder
  96. ansible.posix.synchronize:
  97. src: "{{ app_workspace }}/api-v12"
  98. dest: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}"
  99. recursive: true
  100. - name: Copy ai-translate to release folder
  101. ansible.posix.synchronize:
  102. src: "{{ app_workspace }}/ai-translate"
  103. dest: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}"
  104. recursive: true
  105. # - name: Archive release.tar.xz
  106. # community.general.archive:
  107. # path: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}/*"
  108. # dest: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}.tar.xz"
  109. # format: xz
  110. # remove: true
  111. - name: Archive release.tar.xz
  112. ansible.builtin.command: tar --remove-files -cJf {{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}.tar.xz -C {{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }} .
  113. args:
  114. creates: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}.tar.xz"
  115. environment:
  116. XZ_OPT: "-9"
  117. - name: Download release.tar.xz
  118. ansible.builtin.fetch:
  119. src: "{{ app_workspace }}/tmp/{{ app_domain }}-{{ mint_version }}.tar.xz"
  120. dest: "{{ playbook_dir }}/tmp/"
  121. flat: true