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

Yicong-Huang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new 8841990f1d ci: add temporary AutoQueue workflow as merge-queue 
stand-in (#4672)
8841990f1d is described below

commit 8841990f1d74dc5195d6e760352a3886a7d3a1f2
Author: Yicong Huang <[email protected]>
AuthorDate: Sat May 2 02:21:16 2026 -0700

    ci: add temporary AutoQueue workflow as merge-queue stand-in (#4672)
    
    ## What changes were proposed in this PR?
    
    Adds a small GitHub Actions workflow
    (`.github/workflows/auto-queue.yml`) that runs after every push to
    `main`. It scans open PRs targeting `main` that have auto-merge enabled,
    picks the oldest one whose head is behind `main` (and not
    conflicting/draft), and calls `updateBranch` on it — i.e., merges `main`
    into the PR head so its required CI re-runs and auto-merge can fire.
    
    Picks one PR per main push, serialized via a `concurrency` group, so the
    queue advances at most one step per merge.
    
    ## Any related issues, documentation, discussions?
    
    Refs #4553. This is a temporary stand-in while we wait on the INFRA
    ticket to enable native GitHub Merge Queue. The workflow should be
    deleted once Merge Queue is available on `apache/texera`.
    
    ### Token requirement
    
    The default `GITHUB_TOKEN`'s push to a PR head does **not** retrigger
    required workflows on that PR. To make auto-merge actually fire, set a
    fine-grained PAT (Contents: write, Pull requests: write, Metadata: read)
    as the repo secret `AUTO_MERGE_TOKEN`. The workflow falls back to
    `GITHUB_TOKEN` if the secret is absent (useful for dry-running).
    
    ## How was this PR tested?
    
    Not yet — workflow runs only when on `main`. Plan:
    
    - [ ] Land this PR.
    - [x] Configure `AUTO_MERGE_TOKEN` repo secret.
    - [ ] Verify on the next merge-to-main that the workflow logs identify a
    candidate PR (or "No auto-merge PRs need updating") and that the chosen
    PR's branch gets updated.
    
    Manual sanity-check: `workflow_dispatch` is enabled so it can be invoked
    from the Actions tab without a real merge.
    
    ## Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Opus 4.7 (Claude Code)
    
    Co-authored-by: Yicong Huang <[email protected]>
---
 .github/workflows/auto-queue.yml | 92 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/.github/workflows/auto-queue.yml b/.github/workflows/auto-queue.yml
new file mode 100644
index 0000000000..74918cd2e3
--- /dev/null
+++ b/.github/workflows/auto-queue.yml
@@ -0,0 +1,92 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Temporary stand-in for GitHub Merge Queue.
+# After every push to main, picks the oldest auto-merge-enabled PR whose head
+# is behind main and merges main into it. If a PAT/App token with workflow
+# write is provided as AUTO_MERGE_TOKEN, the resulting push will retrigger the
+# PR's required checks and let auto-merge fire. With GITHUB_TOKEN only, the
+# branch is updated but downstream workflows on the PR are not retriggered.
+name: AutoQueue
+
+on:
+  push:
+    branches: [main]
+  workflow_dispatch:
+
+permissions:
+  contents: write
+  pull-requests: write
+
+concurrency:
+  group: autoqueue-${{ github.repository }}
+  cancel-in-progress: false
+
+jobs:
+  update-next-auto-merge-pr:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/github-script@v7
+        with:
+          github-token: ${{ secrets.AUTO_MERGE_TOKEN || secrets.GITHUB_TOKEN }}
+          script: |
+            const { owner, repo } = context.repo;
+
+            const query = `
+              query($owner:String!, $name:String!) {
+                repository(owner:$owner, name:$name) {
+                  pullRequests(
+                    states: OPEN,
+                    baseRefName: "main",
+                    first: 100,
+                    orderBy: {field: CREATED_AT, direction: ASC}
+                  ) {
+                    nodes {
+                      number
+                      title
+                      isDraft
+                      mergeable
+                      mergeStateStatus
+                      autoMergeRequest { enabledAt }
+                    }
+                  }
+                }
+              }`;
+
+            const data = await github.graphql(query, { owner, name: repo });
+            const candidates = data.repository.pullRequests.nodes.filter(p =>
+              p.autoMergeRequest &&
+              !p.isDraft &&
+              p.mergeable !== 'CONFLICTING' &&
+              p.mergeStateStatus === 'BEHIND'
+            );
+
+            if (candidates.length === 0) {
+              core.info('No auto-merge PRs need updating.');
+              return;
+            }
+
+            const pr = candidates[0];
+            core.info(`Updating PR #${pr.number}: ${pr.title}`);
+
+            try {
+              await github.rest.pulls.updateBranch({
+                owner, repo, pull_number: pr.number,
+              });
+              core.info(`PR #${pr.number} update-branch dispatched.`);
+            } catch (e) {
+              core.setFailed(`updateBranch failed for #${pr.number}: 
${e.message}`);
+            }

Reply via email to