diff --git a/.github/ci.md b/.github/ci.md index fda4983d10ae..4c8182a28779 100644 --- a/.github/ci.md +++ b/.github/ci.md @@ -73,8 +73,8 @@ If they don't match, it describes how to make the updates to include the changes - basic - integration -### close-prs Workflow -[This](./workflows/close-pending.yaml) workflow is scheduled each night at midnight; it closes PR's that have not been updated in the last 21 days, while letting the author know they are free to reopen. +### close-stale-prs Workflow +[This](./workflows/close-stale-prs.yml) workflow is scheduled each night at midnight and uses the [actions/stale](https://github.com/actions/stale) to automatically manage inactive PRs. It marks PRs as stale after 21 days of inactivity and closes them 7 days later. If a stale PR receives any updates or comments, the stale label is automatically removed. ### comment-commands Workflow [This](./workflows/comments.yaml) workflow is triggered each time a comment is added/edited to a PR. It checks to see if the body of the comment begins with one of the following strings and, if so, invokes the corresponding command. diff --git a/.github/close-pending.sh b/.github/close-pending.sh deleted file mode 100755 index 5ed27d31a10c..000000000000 --- a/.github/close-pending.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -# 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. - -set -e - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -MESSAGE=$(cat $SCRIPT_DIR/closing-message.txt) - -while IFS= read -r number && - IFS= read -r title; do - echo "Closing PR ($number): $title" - curl -s -o /dev/null \ - -X POST \ - --data "$(jq --arg body "$MESSAGE" -n '{body: $body}')" \ - --header "authorization: Bearer $GITHUB_TOKEN" \ - --header 'content-type: application/json' \ - "https://api.github.com/repos/apache/ozone/issues/$number/comments" - - curl -s -o /dev/null \ - -X PATCH \ - --data '{"state": "close"}' \ - --header "authorization: Bearer $GITHUB_TOKEN" \ - --header 'content-type: application/json' \ - "https://api.github.com/repos/apache/ozone/pulls/$number" -done < <(curl -H "Content-Type: application/json" \ - --header "authorization: Bearer $GITHUB_TOKEN" \ - "https://api.github.com/search/issues?q=repo:apache/ozone+type:pr+updated:<$(date -d "-21 days" +%Y-%m-%d)+label:pending+is:open" \ - | jq -r '.items[] | (.number,.title)') diff --git a/.github/closing-message.txt b/.github/closing-message.txt deleted file mode 100644 index 261eac275e0e..000000000000 --- a/.github/closing-message.txt +++ /dev/null @@ -1,7 +0,0 @@ -Thank you very much for the patch. I am closing this PR __temporarily__ as there was no activity recently and it is waiting for response from its author. - -It doesn't mean that this PR is not important or ignored: feel free to reopen the PR at any time. - -It only means that attention of committers is not required. We prefer to keep the review queue clean. This ensures PRs in need of review are more visible, which results in faster feedback for all PRs. - -If you need ANY help to finish this PR, please [contact the community](https://github.com/apache/hadoop-ozone#contact) on the mailing list or the slack channel." diff --git a/.github/workflows/close-pending.yaml b/.github/workflows/close-stale-prs.yaml similarity index 50% rename from .github/workflows/close-pending.yaml rename to .github/workflows/close-stale-prs.yaml index 3dfe736cd39d..6e4ef57f88fe 100644 --- a/.github/workflows/close-pending.yaml +++ b/.github/workflows/close-stale-prs.yaml @@ -12,21 +12,27 @@ # 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. -name: close-prs +name: close-stale-prs on: schedule: - - cron: '0 0 * * *' + - cron: '0 0 * * *' jobs: - close-pending: - name: close-pending - runs-on: ubuntu-24.04 + close-stale-prs: + permissions: + pull-requests: write + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Execute close-pending script - if: github.repository == 'apache/ozone' - run: ./.github/close-pending.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Close Stale PRs + uses: actions/stale@v10 + with: + stale-pr-label: 'stale' + exempt-draft-pr: false + days-before-issue-stale: -1 + days-before-pr-stale: 21 + days-before-pr-close: 7 + remove-pr-stale-when-updated: true + operations-per-run: 150 + stale-pr-message: 'This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.' + close-pr-message: 'Thank you for your contribution. This PR is being closed due to inactivity. If needed, feel free to reopen it.'