From 2eaf997dce1c8391d40d95cb194a1c645d7a55c8 Mon Sep 17 00:00:00 2001 From: foxspy Date: Mon, 10 Mar 2025 15:01:05 +0800 Subject: [PATCH] enhance: Automatically Close Knowhere Automated PRs (#40498) Signed-off-by: xianliang.li --- .github/workflows/update-knowhere-commit.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/update-knowhere-commit.yaml b/.github/workflows/update-knowhere-commit.yaml index faf02d2b27..efd563e293 100644 --- a/.github/workflows/update-knowhere-commit.yaml +++ b/.github/workflows/update-knowhere-commit.yaml @@ -25,6 +25,30 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Install GitHub CLI + run: | + sudo apt update + sudo apt install -y gh + - name: Close Previous PRs + run: | + REPO=${{ github.repository }} + + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + # Set up GitHub CLI authentication non-interactively + gh auth login --with-token <<< "${{ secrets.ALL_CONTRIBUTORS_TOKEN }}" + + BRANCH_PREFIX="update_knowhere_commit_" + + prs=$(gh pr list --repo "$REPO" --state open --json number,headRefName --jq ".[] | select(.headRefName | startswith(\"$BRANCH_PREFIX\")) | .number") + + for pr in $prs; do + echo "Closing old PR #$pr" + gh pr close $pr --repo "$REPO" + done + env: + GH_TOKEN: ${{ secrets.ALL_CONTRIBUTORS_TOKEN }} - name: get knowhere latest commit id: get-knowhere-latest-commit run: |