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.

115 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. if ! $( echo "$BRANCH" | grep -E "^(master|[0-9]+\.[0-9]+)(-dev-.+)?$" )
  42. then
  43. echo "This branch is not supposed to be a target of pull requests, so docker image is not needed."
  44. echo "For information check https://github.com/itpp-labs/DINAR/issues/60"
  45. exit 1
  46. fi
  47. rebuild-images:
  48. runs-on: ubuntu-latest
  49. needs:
  50. - check-secret
  51. - check-branch
  52. steps:
  53. - name: Checkout Repo
  54. uses: actions/checkout@v2
  55. with:
  56. path: REPO
  57. - name: Checkout DINAR
  58. uses: actions/checkout@v2
  59. with:
  60. path: DINAR
  61. repository: itpp-labs/DINAR-fork
  62. ref: master
  63. - uses: actions/setup-python@v1
  64. with:
  65. python-version: "3.7.x"
  66. - name: Prepare build folder
  67. run: |
  68. cp -rnT DINAR/embedded-files/ REPO/
  69. - name: Configure Docker
  70. run: |
  71. bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN }}
  72. cat <<- EOF > REPO/.DINAR/image/.netrc
  73. machine github.com
  74. login $GITHUB_ACTOR
  75. password ${{ secrets.DINAR_TOKEN }}
  76. EOF
  77. - name: dinar-odoo-base
  78. uses: elgohr/Publish-Docker-Github-Action@master
  79. env:
  80. LOCAL_CUSTOM_DIR: ./image
  81. AGGREGATE: true
  82. PIP_INSTALL_ODOO: false
  83. CLEAN: false
  84. COMPILE: false
  85. with:
  86. name: ${{ env.IMAGE_ODOO }}-base
  87. registry: ${{ env.REGISTRY }}
  88. username: ${{ env.REGISTRY_USERNAME }}
  89. password: ${{ env.REGISTRY_PASSWORD }}
  90. buildargs: ODOO_VERSION,AGGREGATE,PIP_INSTALL_ODOO,CLEAN,COMPILE,LOCAL_CUSTOM_DIR
  91. workdir: REPO/.DINAR/
  92. - name: Install python tools
  93. run: |
  94. pip install plumbum pyyaml
  95. - name: Compute Modules Dependencies
  96. run: |
  97. # sets environment variables that available in next steps via $ {{ env.VAR_NAME }} notation
  98. cd REPO
  99. python ../DINAR/workflow-files/analyze-modules.py all
  100. - name: Install Base Addons
  101. run: |
  102. export MODULES=$ALL_MODULES_DEPENDENCIES
  103. export DOODBA_WITHOUT_DEMO=all
  104. bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB-nodemo $IMAGE_ODOO-nodemo
  105. export DOODBA_WITHOUT_DEMO=false
  106. bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB $IMAGE_ODOO