|
1 | | -# Copyright (c) 2022-2024, NVIDIA CORPORATION. |
| 1 | +# Copyright (c) 2022-2025, NVIDIA CORPORATION. |
2 | 2 | # |
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | # you may not use this file except in compliance with the License. |
|
22 | 22 | types: [closed] |
23 | 23 |
|
24 | 24 | jobs: |
25 | | - auto-merge: # TODO: use spark-rapids-common shared action when available |
| 25 | + auto-merge: |
26 | 26 | if: github.event.pull_request.merged == true |
27 | | - runs-on: ubuntu-latest |
28 | | - |
29 | | - steps: |
30 | | - - name: set HEAD ENV |
31 | | - run: echo "HEAD=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV |
32 | | - |
33 | | - - name: Generate target branch |
34 | | - run: | |
35 | | - current_branch="${{ env.HEAD }}" |
36 | | - version=${current_branch#branch-} |
37 | | -
|
38 | | - IFS='.' read -r -a parts <<< "$version" |
39 | | - year=${parts[0]} |
40 | | - month=${parts[1]} |
41 | | - month=$((10#$month + 2)) |
42 | | - if [ $month -gt 12 ]; then |
43 | | - month=$((month - 12)) |
44 | | - year=$((year + 1)) |
45 | | - fi |
46 | | -
|
47 | | - next_release=$(printf "%02d.%02d" $year $month) |
48 | | - echo "Next release is $next_release" |
49 | | - echo "BASE=branch-$next_release" >> $GITHUB_ENV |
50 | | -
|
51 | | - - name: Check if target branch exists |
52 | | - run: | |
53 | | - CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.AUTOMERGE_TOKEN }}" \ |
54 | | - https://api.github.com/repos/${{ github.repository }}/branches/${{ env.BASE }}) |
55 | | - echo "Response code: $CODE..." |
56 | | -
|
57 | | - if [ $CODE -eq 200 ]; then |
58 | | - echo "branch_exists=true" >> $GITHUB_ENV |
59 | | - else |
60 | | - echo "branch_exists=false" >> $GITHUB_ENV |
61 | | - echo "Failed to find ${{ env.BASE }}. Skip auto-merge..." |
62 | | - fi |
63 | | -
|
64 | | - - uses: actions/checkout@v4 |
65 | | - if: env.branch_exists == 'true' |
66 | | - with: |
67 | | - ref: ${{ env.HEAD }} # force to fetch from latest upstream instead of PR ref |
68 | | - token: ${{ secrets.AUTOMERGE_TOKEN }} # workaround auto-merge token to avoid GITHUB_TOKEN insufficient permission |
69 | | - |
70 | | - - name: push intermediate branch for auto-merge |
71 | | - if: env.branch_exists == 'true' |
72 | | - run: | |
73 | | - git config user.name "spark-rapids automation" |
74 | | - git config user.email "[email protected] " |
75 | | - git fetch origin ${HEAD} ${BASE} |
76 | | - git checkout -b ${INTERMEDIATE_HEAD} origin/${HEAD} |
77 | | - # Sync the $BASE branch with the commits from the $HEAD branch, |
78 | | - # excluding the paths defined as $FILE_USE_BASE (located under ./thirdparty). |
79 | | - git checkout origin/${BASE} -- ${FILE_USE_BASE} |
80 | | - # If any submodule file is updated in the HEAD branch, |
81 | | - # always change it to the corresponding one from the BASE branch. |
82 | | - [ ! -z "$(git status --porcelain=v1 --untracked=no)" ] && \ |
83 | | - git commit -s -am "Auto-merge use ${BASE} versions" |
84 | | - git push origin ${INTERMEDIATE_HEAD} -f |
85 | | - env: |
86 | | - INTERMEDIATE_HEAD: bot-auto-merge-${{ env.HEAD }} |
87 | | - FILE_USE_BASE: thirdparty/cudf thirdparty/cudf-pins |
88 | | - |
89 | | - - name: auto-merge job |
90 | | - if: env.branch_exists == 'true' |
91 | | - uses: ./.github/workflows/action-helper |
92 | | - with: |
93 | | - operator: auto-merge |
94 | | - env: |
95 | | - OWNER: NVIDIA |
96 | | - REPO: spark-rapids-jni |
97 | | - HEAD: bot-auto-merge-${{ env.HEAD }} |
98 | | - BASE: ${{ env.BASE }} |
99 | | - TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} |
| 27 | + uses: NVIDIA/spark-rapids-common/.github/workflows/auto-merge.yml@main |
| 28 | + with: |
| 29 | + owner: ${{ github.repository_owner }} |
| 30 | + repo: spark-rapids-jni |
| 31 | + branch: ${{ github.event.pull_request.base.ref }} |
| 32 | + file_use_base: 'thirdparty/cudf thirdparty/cudf-pins' |
| 33 | + secrets: |
| 34 | + token: ${{ secrets.AUTOMERGE_TOKEN }} |
0 commit comments