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.

118 lines
4.5 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: "Port module"
  15. on:
  16. issues:
  17. types:
  18. - opened
  19. - reopened
  20. jobs:
  21. port:
  22. runs-on: ubuntu-latest
  23. if: "startsWith(github.event.issue.title, 'DINAR-PORT ')"
  24. steps:
  25. - name: Post a message
  26. uses: KeisukeYamashita/create-comment@v1
  27. with:
  28. comment:
  29. "Porting is started. Check logs: https://github.com/${{ github.repository
  30. }}/actions/runs/${{ github.run_id }}"
  31. - name: Checkout DINAR
  32. uses: actions/checkout@v2
  33. with:
  34. path: DINAR
  35. repository: itpp-labs/DINAR-fork
  36. ref: master
  37. - uses: actions/setup-python@v2
  38. with:
  39. python-version: "3.7.x"
  40. - name: Install python tools
  41. run: |
  42. pip install plumbum pre-commit git-aggregator
  43. - name: Check Python Version
  44. run:
  45. echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >>
  46. $GITHUB_ENV
  47. - name: Checkout Repo
  48. uses: actions/checkout@v2
  49. with:
  50. path: REPO
  51. fetch-depth: 0
  52. ref: ${{ env.PORT_TO_BRANCH }}
  53. - uses: actions/cache@v1
  54. with:
  55. path: ~/.cache/pre-commit
  56. key: pre-commit|${{ env.PY }}|${{ hashFiles('REPO/.pre-commit-config.yaml') }}
  57. - name: Analyze request
  58. run: |
  59. # sets environment variables that available in next steps via $ {{ env.PORT_... }} notation
  60. python DINAR/workflow-files/analyze_port_trigger.py "${{ github.event.issue.title }}"
  61. - name: Copy module to new branch
  62. run: |
  63. git config --global user.email "itpp-bot@users.noreply.github.com"
  64. git config --global user.name "Mitchell Admin"
  65. cd REPO
  66. if [ ! -d ${{ env.PORT_MODULE }} ]
  67. then
  68. # apply original commit history
  69. if ! git format-patch --keep-subject --stdout origin/${{ env.PORT_TO_BRANCH }}..origin/${{ env.PORT_FROM_BRANCH }} -- ${{ env.PORT_MODULE }} | git am -3 --keep
  70. then
  71. # git am failed
  72. git am --abort
  73. # just copy source
  74. git checkout origin/${{ env.PORT_FROM_BRANCH }} -- ${{ env.PORT_MODULE }}
  75. git commit -m ":tada:${{ env.PORT_FROM_BRANCH_TAGS }} ${{ env.PORT_MODULE }}
  76. previous commits history: https://github.com/${{ github.repository }}/commits/${{ env.PORT_FROM_BRANCH }}/ir_rule_protected
  77. > Made via .github/workflows/DINAR-PORT.yml"
  78. fi
  79. fi
  80. - name: make OCA/odoo-module-migrator
  81. run: |
  82. gitaggregate -c DINAR/workflow-files/odoo-module-migrator-mix.yml
  83. pip install -e ./odoo-module-migrator
  84. - name: apply OCA/odoo-module-migrator
  85. run: |
  86. cd REPO
  87. odoo-module-migrate \
  88. --modules ${{ env.PORT_MODULE }} \
  89. --init-version-name ${{ env.PORT_FROM_BRANCH }} \
  90. --target-version-name ${{ env.PORT_TO_BRANCH }} \
  91. --no-commit
  92. git add -A
  93. git commit -m ":arrow_up:${{ env.PORT_TO_BRANCH_TAGS }} OCA/odoo-module-migrator
  94. close #${{ github.event.issue.number }}
  95. > Made via .github/workflows/DINAR-PORT.yml"
  96. - name: pre-commit
  97. run: |
  98. cd REPO
  99. pre-commit run --files $(find ${{ env.PORT_MODULE }} -type f) || true
  100. git add -A
  101. git commit -m ":rainbow: pre-commit
  102. > Made via .github/workflows/DINAR-PORT.yml" || echo "pre-commit: no changes"
  103. - name: PR
  104. uses: peter-evans/create-pull-request@v3
  105. with:
  106. path: REPO
  107. # GITHUB_TOKEN would not trigger PR checks
  108. token: ${{ secrets.DINAR_TOKEN }}
  109. branch: ${{ env.PORT_TO_BRANCH }}-${{ env.PORT_MODULE }}
  110. title: "[${{ env.PORT_TO_BRANCH }}] ${{ env.PORT_MODULE }}"
  111. body: |
  112. Made by [DINAR](https://github.com/itpp-labs/DINAR#readme) by request in #${{ github.event.issue.number }}