Skip to content

Add cron based policies #483

Open
Open
@TRAD-Anthony-CKO

Description

@TRAD-Anthony-CKO

Is your feature request related to a problem? Please describe.
I wanted to write a policy that auto-close some PRs after a certain time (5 Days for example). I didn't find anything about supporting scheduled runs in policies. Is that supported somewhere? Any example I can use as a baseline?

Describe the solution you'd like
Here's an example policy I tried to write:

# -*- mode: yaml -*-

manifest:
  version: 1.0

automations:
  auto_close_old_prs:
    schedule:
      cron: "0 0 * * *"
    if:
      - {{ pull_request.age_days > 10 }}
      - {{ 'auto-close' in pull_request.labels }}
    run:
      - action: close-pr@v1
        args:
          reason: "This PR has been automatically closed as it has been open for more than 10 days without being merged or updated and is tagged with 'auto-close'. Please feel free to reopen or create a new PR if the changes are still relevant."

pull_request:
  age_days: {{ now() | date:'Y-m-d' | diff(pull_request.created_at | date:'Y-m-d') | days }}
  labels: {{ pull_request.labels | map(attribute='name') }}  

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions