mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-12-03 02:50:29 +01:00
76 lines
2.7 KiB
YAML
76 lines
2.7 KiB
YAML
name: PR Limits
|
|
|
|
# Deterministic PR rules from CONTRIBUTING.md: the open PR limit, the conflict
|
|
# window, and the 72 hour close window that follows a triage notice.
|
|
#
|
|
# Nothing is labeled, commented on, or closed until the repository variable
|
|
# PR_LIMITS_ENFORCE is "true". Until then every run logs what it would do. A
|
|
# sweep reads the variable once when it starts; to stop one, cancel the run.
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, reopened]
|
|
schedule:
|
|
- cron: "23 5 * * *"
|
|
workflow_dispatch:
|
|
inputs:
|
|
dry_run:
|
|
description: Log what the sweep would do without labeling, commenting, or closing.
|
|
type: boolean
|
|
default: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
open-limit:
|
|
name: Open PR limit
|
|
if: github.event_name == 'pull_request_target'
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
steps:
|
|
# pull_request_target has a write token. Load the script from the default
|
|
# branch and never run PR code. Cone mode also checks out the files beside
|
|
# .github/scripts, which is where TRIAGE_EXEMPTIONS.td and VOUCHED.td live.
|
|
- name: Checkout trusted scripts
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
ref: ${{ github.event.repository.default_branch }}
|
|
sparse-checkout: .github/scripts
|
|
|
|
- name: Close PRs over the limit
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
env:
|
|
DRY_RUN: ${{ vars.PR_LIMITS_ENFORCE != 'true' }}
|
|
with:
|
|
script: |
|
|
const limits = require("./.github/scripts/pr-limits.cjs");
|
|
await limits.enforceOpenLimit({ github, context, core, dryRun: process.env.DRY_RUN === "true" });
|
|
|
|
sweep:
|
|
name: Conflict and close windows
|
|
if: github.event_name != 'pull_request_target'
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
concurrency:
|
|
group: pr-limits-sweep
|
|
cancel-in-progress: false
|
|
steps:
|
|
- name: Checkout trusted scripts
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
ref: ${{ github.event.repository.default_branch }}
|
|
sparse-checkout: .github/scripts
|
|
|
|
- name: Request rebases and close what went unanswered
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
env:
|
|
DRY_RUN: ${{ vars.PR_LIMITS_ENFORCE != 'true' || (github.event_name == 'workflow_dispatch' && inputs.dry_run) }}
|
|
with:
|
|
script: |
|
|
const limits = require("./.github/scripts/pr-limits.cjs");
|
|
await limits.sweep({ github, context, core, dryRun: process.env.DRY_RUN === "true" });
|