Skip to content

Commit b54cf5d

Browse files
committed
tools: respect 7 days wait commit-queue with one approval
1 parent 8ea96e6 commit b54cf5d

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tools/actions/commit-queue.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ for pr in "$@"; do
4545
continue
4646
fi
4747

48+
# Skip PR if it has only one approval and was created less than 7 days ago
49+
pr_meta=$(gh pr view "$pr" --json reviews,createdAt)
50+
approvals=$(echo "$pr_meta" | jq '[.reviews[] | select(.state == "APPROVED")] | unique_by(.author.login) | length')
51+
created_at=$(echo "$pr_meta" | jq -r '.createdAt')
52+
created_epoch=$(date -d "$created_at" +%s)
53+
seven_days_ago=$(date -d "7 days ago" +%s)
54+
if [ "$approvals" -le 1 ] && [ "$created_epoch" -gt "$seven_days_ago" ]; then
55+
echo "pr ${pr} skipped, only one approval and created less than 7 days ago"
56+
continue
57+
fi
58+
4859
# Delete the commit queue label
4960
gh pr edit "$pr" --remove-label "$COMMIT_QUEUE_LABEL"
5061

0 commit comments

Comments
 (0)