sync_cmakebuild.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. name: Sync cmakebuild with main
  2. on:
  3. schedule:
  4. <<<<<<< HEAD
  5. - cron: "0 * * * *" # At minute 0 every hour
  6. =======
  7. - cron: "0 * * * *"
  8. >>>>>>> stable-24-1
  9. workflow_dispatch:
  10. concurrency:
  11. group: ${{ github.workflow }}
  12. cancel-in-progress: true
  13. env:
  14. REPO: ${{ github.repository }}
  15. TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  16. jobs:
  17. sync:
  18. runs-on: ubuntu-latest
  19. steps:
  20. - name: Sync
  21. run: |
  22. mainsha=$(curl -s -H "Accept: application/vnd.github.VERSION.sha" https://api.github.com/repos/$REPO/commits/main)
  23. echo "Main sha: ${mainsha}"
  24. lastsha=$(curl -s https://raw.githubusercontent.com/$REPO/cmakebuild/ydb/ci/cmakegen.txt)
  25. echo "Last sha: ${lastsha}"
  26. if [ "${mainsha}" == "${lastsha}" ];then
  27. echo "No new commits on the main branch to merge, exiting"
  28. exit 0
  29. fi
  30. git clone -b main --shallow-exclude cmakebuild https://$TOKEN@github.com/$REPO.git ydb
  31. git config --global user.email "alex@ydb.tech"
  32. git config --global user.name "Alexander Smirnov"
  33. cd ydb
  34. git fetch --depth `expr $(git rev-list --count HEAD) + 1`
  35. # Depth 10: 1st with cmake generation, 2nd with previous merge, 3rd is common between main and cmakebuild,
  36. # others for possible commits directly on cmakebuild branch
  37. git fetch origin cmakebuild:cmakebuild --depth 10
  38. mainsha=$(git rev-parse HEAD)
  39. git checkout cmakebuild
  40. prevsha=$(git rev-parse HEAD)
  41. git merge main --no-edit
  42. currsha=$(git rev-parse HEAD)
  43. if [ ${prevsha} == ${currsha} ];then
  44. echo "Merge did not bring any changes, exiting"
  45. exit
  46. fi
  47. ./generate_cmake -k
  48. echo ${mainsha} > ydb/ci/cmakegen.txt
  49. git add .
  50. git commit -m "Generate cmake for ${mainsha}"
  51. git push --set-upstream origin cmakebuild