This is an automated email from the ASF dual-hosted git repository.

hello-stephen pushed a commit to branch ci/auto-pick-42-buildall
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 2b075c6e4784409b175d7442e541d56397da4626
Author: lidongyang <[email protected]>
AuthorDate: Thu Oct 15 16:42:23 2026 +0800

    [fix](build) Trigger buildall for branch-4.2 auto-pick PRs
    
    ### What problem does this PR solve?
    
    Issue Number: None
    
    Related PR: #69097
    
    Problem Summary: Auto-picked branch-4.2 PRs are created with GITHUB_TOKEN, 
so their creation does not start the issue-comment workflow. Dispatch the 
existing buildall workflow after a PR is created and validate its current head 
before triggering CI.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test: Manual test (actionlint, Python syntax, dispatch validation against 
#69097)
    
    - Behavior changed: Yes (new branch-4.2 auto-pick PRs automatically run 
buildall)
    
    - Does this need documentation: No
---
 .github/workflows/auto-cherry-pick.yml            | 16 +++++++-
 .github/workflows/comment-to-trigger-teamcity.yml | 47 ++++++++++++++++++-----
 tools/auto-pick-script.py                         |  6 ++-
 3 files changed, 58 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/auto-cherry-pick.yml 
b/.github/workflows/auto-cherry-pick.yml
index ade803a6eeb..bf79b9c074f 100644
--- a/.github/workflows/auto-cherry-pick.yml
+++ b/.github/workflows/auto-cherry-pick.yml
@@ -25,6 +25,7 @@ on:
     branches:
       - master
 permissions:
+  actions: write
   checks: write
   contents: write
   pull-requests: write
@@ -50,7 +51,7 @@ jobs:
       - name: Check SHA
         id: check_sha
         run: |
-            
expected_sha="5439ca6304c986a5b26e8f48d528253909b417597088fe98969afee5c2eccbe6d60c5cd1eb03d452eb8082ce2a8ff4ea18854770375487a30bd4af7af9afd322"
+            
expected_sha="528eabe0941e95bba64751e85dfd6c1539edad7cdf5753267d5f9d991b2359d065dfc76bcb8a69e904f25cb07e16dbc620d01f3a4f40d006f106ff34553d75aa"
             calculated_sha=$(sha512sum tools/auto-pick-script.py | awk '{ 
print $1 }')
             if [ "$calculated_sha" != "$expected_sha" ]; then
               echo "SHA mismatch! Expected: $expected_sha, but got: 
$calculated_sha"
@@ -78,6 +79,7 @@ jobs:
           python tools/auto-pick-script.py ${{ 
github.event.pull_request.number }} branch-4.1
 
       - name: Auto cherry-pick to branch-4.2
+        id: auto_pick_42
         if: >-
           ${{ !cancelled() && steps.check_sha.outcome == 'success' &&
               contains(github.event.pull_request.labels.*.name, 'dev/4.2.x') &&
@@ -89,3 +91,15 @@ jobs:
           CONFLICT_LABEL: dev/4.2.x-conflict
         run: |
           python tools/auto-pick-script.py ${{ 
github.event.pull_request.number }} branch-4.2
+
+      - name: Run buildall for the branch-4.2 PR
+        if: ${{ !cancelled() && steps.auto_pick_42.outputs.pr_number != '' }}
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          AUTO_PICK_PR_NUMBER: ${{ steps.auto_pick_42.outputs.pr_number }}
+          AUTO_PICK_HEAD_SHA: ${{ steps.auto_pick_42.outputs.head_sha }}
+        run: |
+          set -euo pipefail
+          gh api -X POST 
"repos/${GITHUB_REPOSITORY}/actions/workflows/comment-to-trigger-teamcity.yml/dispatches"
 \
+            -f ref=master -f "inputs[pr_number]=${AUTO_PICK_PR_NUMBER}" \
+            -f "inputs[head_sha]=${AUTO_PICK_HEAD_SHA}"
diff --git a/.github/workflows/comment-to-trigger-teamcity.yml 
b/.github/workflows/comment-to-trigger-teamcity.yml
index 89cfbaa2348..37b272239fc 100644
--- a/.github/workflows/comment-to-trigger-teamcity.yml
+++ b/.github/workflows/comment-to-trigger-teamcity.yml
@@ -20,6 +20,16 @@ name: Comment to trigger teamcity
 on:
   issue_comment:
     types: [created, edited]
+  workflow_dispatch:
+    inputs:
+      pr_number:
+        description: Branch-4.2 auto-pick PR number
+        required: true
+        type: string
+      head_sha:
+        description: Auto-pick PR head SHA at creation
+        required: true
+        type: string
 
 permissions:
   contents: read
@@ -33,9 +43,10 @@ jobs:
     # A generic "run" match also catches performance reports such as "Total 
hot run time".
     if: >-
       ${{
-        github.event.issue.pull_request &&
-        !startsWith(github.event.comment.body, '/review') &&
-        (
+        github.event_name == 'workflow_dispatch' ||
+        (github.event.issue.pull_request &&
+         !startsWith(github.event.comment.body, '/review') &&
+         (
           contains(github.event.comment.body, 'run buildall') ||
           contains(github.event.comment.body, 'run compile') ||
           contains(github.event.comment.body, 'run beut') ||
@@ -52,14 +63,15 @@ jobs:
           contains(github.event.comment.body, 'run performance') ||
           contains(github.event.comment.body, 'skip buildall') ||
           contains(github.event.comment.body, 'skip check_coverage')
-        )
+         ))
       }}
 
     # Serialize duplicate commands for one PR. The next run then sees the build
     # queued by the previous run and can safely skip an identical PR revision.
     concurrency:
       group: >-
-        comment-to-trigger-teamcity-${{ github.event.issue.number }}-${{
+        comment-to-trigger-teamcity-${{ github.event.issue.number || 
inputs.pr_number }}-${{
+          github.event_name == 'workflow_dispatch' && 'buildall' ||
           contains(github.event.comment.body, 'run buildall') && 'buildall' ||
           contains(github.event.comment.body, 'run compile') && 'compile' ||
           contains(github.event.comment.body, 'run beut') && 'beut' ||
@@ -81,8 +93,11 @@ jobs:
 
     runs-on: ubuntu-latest
     env:
-      COMMENT_BODY: ${{ github.event.comment.body }}
+      COMMENT_BODY: ${{ github.event_name == 'workflow_dispatch' && 'run 
buildall' || github.event.comment.body }}
       COMMENT_USER_ID: ${{ github.event.comment.user.id }}
+      PULL_REQUEST_NUM: ${{ github.event.issue.number || inputs.pr_number }}
+      DISPATCH_HEAD_SHA: ${{ inputs.head_sha }}
+      TRIGGER_EVENT: ${{ github.event_name }}
       GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
     steps:
@@ -90,9 +105,23 @@ jobs:
       id: parse
       run: |
         COMMENT_BODY=$(echo "${COMMENT_BODY}" | xargs)
-        PULL_REQUEST_NUM="$(echo "${{ github.event.issue.pull_request.url }}" 
| awk -F/ '{print $NF}')"
-        COMMIT_ID_FROM_TRIGGER="$(curl -s -H "Authorization:Bearer ${{ 
secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository 
}}/pulls/${PULL_REQUEST_NUM}" | jq -r '.head.sha')"
-        TARGET_BRANCH="$(curl -s -H "Authorization:Bearer ${{ 
secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository 
}}/pulls/${PULL_REQUEST_NUM}" | jq -r '.base.ref')"
+        [[ "${PULL_REQUEST_NUM}" =~ ^[0-9]+$ ]] || exit 1
+        pr_json="$(curl -fsS -H "Authorization:Bearer ${GITHUB_TOKEN}" \
+          
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PULL_REQUEST_NUM}";)"
+        COMMIT_ID_FROM_TRIGGER="$(jq -r '.head.sha' <<< "$pr_json")"
+        TARGET_BRANCH="$(jq -r '.base.ref' <<< "$pr_json")"
+        if [[ "${TRIGGER_EVENT}" == 'workflow_dispatch' ]]; then
+          [[ "${DISPATCH_HEAD_SHA}" =~ ^[0-9a-f]{40}$ ]] || exit 1
+          jq -e --arg sha "${DISPATCH_HEAD_SHA}" --arg repo 
"${GITHUB_REPOSITORY}" '
+            .state == "open" and .base.ref == "branch-4.2" and
+            .head.sha == $sha and .head.repo.full_name == $repo and
+            (.head.ref | test("^auto-pick-[0-9]+-branch-4[.]2$")) and
+            .user.login == "github-actions[bot]"
+          ' <<< "$pr_json" > /dev/null || {
+            echo 'Workflow dispatch must identify the current head of an open 
branch-4.2 auto-pick PR.'
+            exit 1
+          }
+        fi
         if [[ "${COMMENT_BODY}" == *'run buildall'* ||
             "${COMMENT_BODY}" == *'run compile'* ||
             "${COMMENT_BODY}" == *'run beut'* ||
diff --git a/tools/auto-pick-script.py b/tools/auto-pick-script.py
index b8bb9358820..52cb9426436 100644
--- a/tools/auto-pick-script.py
+++ b/tools/auto-pick-script.py
@@ -103,6 +103,10 @@ try:
             base=TARGET_BRANCH
         )
         print(f"Created a new PR #{new_pr.number} for cherry-picked changes.")
+        if output_path := os.getenv('GITHUB_OUTPUT'):
+            with open(output_path, 'a') as output:
+                output.write(f"pr_number={new_pr.number}\n")
+                output.write(f"head_sha={new_pr.head.sha}\n")
     else:
         print(f"Commit {merge_commit_sha} was not found in {new_branch_name} 
after cherry-picking.")
 
@@ -113,4 +117,4 @@ except subprocess.CalledProcessError:
     print(f"Added label '{CONFLICT_LABEL}' to PR #{pr.number} due to 
conflict.")
     subprocess.run(["git", "checkout", "master", "-f"], cwd=repo_dir, 
check=True)
     subprocess.run(["git", "branch", "-D", new_branch_name], cwd=repo_dir)
-    subprocess.run(["git", "push", "origin", "--delete", new_branch_name], 
cwd=repo_dir)
\ No newline at end of file
+    subprocess.run(["git", "push", "origin", "--delete", new_branch_name], 
cwd=repo_dir)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to