You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.7 KiB

  1. # Copyright 2020 IT Projects Labs
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. name: "DINAR: Docker Image Building"
  15. on:
  16. push:
  17. paths:
  18. - ".DINAR/**"
  19. - ".github/workflows/DINAR.yml"
  20. # Cron works only for defaul branch. See https://github.com/itpp-labs/DINAR/issues/48
  21. schedule:
  22. - cron: "5 5 * * 0"
  23. jobs:
  24. check-secret:
  25. runs-on: ubuntu-latest
  26. steps:
  27. - name: Check that DINAR_TOKEN is set
  28. run: |
  29. if [ -z "${{ secrets.DINAR_TOKEN }}" ]
  30. then
  31. echo "DINAR_TOKEN is not set"
  32. exit 1
  33. fi
  34. check-branch:
  35. runs-on: ubuntu-latest
  36. steps:
  37. - name: Check that this branch needs docker images
  38. run: |
  39. REF=${GITHUB_BASE_REF:-${GITHUB_REF}}
  40. BRANCH=${REF##*/}
  41. CHECK=$( echo "$BRANCH" | grep -E "^(master|[0-9]+\.[0-9]+)(-dev-.+)?$" || true)
  42. if [ -z "$CHECK" ]
  43. then
  44. echo "This branch is not supposed to be a target of pull requests, so docker image is not needed."
  45. echo "For information check https://github.com/itpp-labs/DINAR/issues/60"
  46. exit 1
  47. fi
  48. rebuild-images:
  49. runs-on: ubuntu-latest
  50. needs:
  51. - check-secret
  52. - check-branch
  53. steps:
  54. - name: Checkout Repo
  55. uses: actions/checkout@v2
  56. with:
  57. path: REPO
  58. - name: Checkout DINAR
  59. uses: actions/checkout@v2
  60. with:
  61. path: DINAR
  62. repository: itpp-labs/DINAR-fork
  63. ref: master
  64. - uses: actions/setup-python@v1
  65. with:
  66. python-version: "3.7.x"
  67. - name: Prepare build folder
  68. run: |
  69. cp -rnT DINAR/embedded-files/ REPO/
  70. - name: Configure Docker
  71. run: |
  72. bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN }}
  73. cat <<- EOF > REPO/.DINAR/image/.netrc
  74. machine github.com
  75. login $GITHUB_ACTOR
  76. password ${{ secrets.DINAR_TOKEN }}
  77. EOF
  78. - name: Build ${{ env.IMAGE_ODOO_BASE }}
  79. uses: elgohr/Publish-Docker-Github-Action@master
  80. env:
  81. LOCAL_CUSTOM_DIR: ./image
  82. AGGREGATE: true
  83. PIP_INSTALL_ODOO: false
  84. CLEAN: false
  85. COMPILE: false
  86. with:
  87. name: ${{ env.IMAGE_ODOO_BASE }}
  88. registry: ${{ env.REGISTRY }}
  89. username: ${{ env.REGISTRY_USERNAME }}
  90. password: ${{ env.REGISTRY_PASSWORD }}
  91. buildargs: ODOO_VERSION,AGGREGATE,PIP_INSTALL_ODOO,CLEAN,COMPILE,LOCAL_CUSTOM_DIR
  92. workdir: REPO/.DINAR/
  93. - name: Install python tools
  94. run: |
  95. pip install plumbum pyyaml
  96. - name: Compute Modules Dependencies
  97. run: |
  98. # sets environment variables that available in next steps via $ {{ env.VAR_NAME }} notation
  99. cd REPO
  100. python ../DINAR/workflow-files/analyze-modules.py all
  101. - name: Install Base Addons
  102. run: |
  103. export MODULES=$ALL_MODULES_DEPENDENCIES
  104. export DOODBA_WITHOUT_DEMO=all
  105. bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB-nodemo $IMAGE_ODOO-nodemo
  106. export DOODBA_WITHOUT_DEMO=false
  107. bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB $IMAGE_ODOO