diff options
-rw-r--r-- | .github/workflows/sync_cmakebuild.yml | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/.github/workflows/sync_cmakebuild.yml b/.github/workflows/sync_cmakebuild.yml index 878675d9ef..ae227c2020 100644 --- a/.github/workflows/sync_cmakebuild.yml +++ b/.github/workflows/sync_cmakebuild.yml @@ -3,21 +3,43 @@ on: schedule: - cron: "0 * * * *" workflow_dispatch: - inputs: - test_label_regexp: - required: false - type: string +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true +env: + REPO: ${{ github.repository }} + TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} jobs: - build: + sync: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - ref: cmakebuild - name: Sync run: | - git checkout main -- ydb/ci/sync_cmakebuild.sh - cp ydb/ci/sync_cmakebuild.sh ~ - git restore ydb/ci/sync_cmakebuild.sh - ~/sync_cmakebuild.sh - git push + mainsha=$(curl -s -H "Accept: application/vnd.github.VERSION.sha" https://api.github.com/repos/$REPO/commits/main) + echo "Main sha: ${mainsha}" + lastsha=$(curl -s https://raw.githubusercontent.com/$REPO/cmakebuild/ydb/ci/cmakegen.txt) + echo "Last sha: ${lastsha}" + if [ ${mainsha} == ${lastsha} ];then + echo "No new commits on the main branch to merge, exiting" + exit 0 + fi + git clone -b main --shallow-exclude cmakebuild https://$TOKEN@github.com/$REPO.git ydb + git config --global user.email "alex@ydb.tech" + git config --global user.name "Alexander Smirnov" + cd ydb + git fetch --depth `expr $(git rev-list --count HEAD) + 1` + git fetch origin cmakebuild:cmakebuild --depth 3 # 1st with cmake generation, 2nd with previous merge, 3rd is common between main and cmakebuild + mainsha=$(git rev-parse HEAD) + git checkout cmakebuild + prevsha=$(git rev-parse HEAD) + git merge main --no-edit + currsha=$(git rev-parse HEAD) + if [ ${prevsha} == ${currsha} ];then + echo "Merge did not bring any changes, exiting" + exit + fi + ./generate_cmake -k + echo ${mainsha} > ydb/ci/cmakegen.txt + git add . + git commit -m "Generate cmake for ${mainsha}" + git push --set-upstream origin cmakebuild |