Files
velero/.github/workflows/auto_assign_prs.yml
T

53 lines
2.1 KiB
YAML

---
name: "Auto Assign Author"
# pull_request_target means that this will run on pull requests, but in
# the context of the base repo. This should mean PRs from forks are supported.
on:
pull_request_target:
types: [opened, reopened, ready_for_review]
# Watch for submitted reviews so we can record the PR number for the
# privileged re-request-review workflow (see re_request_review.yml).
# NOTE: For fork-originated PRs the GITHUB_TOKEN on pull_request_review is
# read-only even when pull-requests: write is declared, so the actual
# requestReviewers API call is delegated to a workflow_run workflow that
# receives a write token regardless of fork status.
pull_request_review:
types: [submitted]
permissions:
contents: read
pull-requests: write
jobs:
# Automatically assigns reviewers and owner
add-reviews:
if: github.repository == 'velero-io/velero' && github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
steps:
- name: Set the author of a PR as the assignee
uses: kentaro-m/auto-assign-action@v2.0.2
with:
configuration-path: ".github/auto-assignees.yml"
# `.github/CODEOWNERS` automatically requests review from the
# velero-io/maintainer team, but that request is cleared as soon as a
# single member of the team submits a review. Since we require a minimum
# of 2 reviewers (see `number_of_reviewers` in auto-assignees.yml), record
# the PR number here so the privileged re_request_review.yml workflow can
# safely re-request a review from the maintainer team.
record-pr-number:
if: github.repository == 'velero-io/velero' && github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- name: Save PR number to artifact
run: |
mkdir -p /tmp/pr
# Write only the numeric PR number; the privileged workflow validates this.
printf '%s' '${{ github.event.pull_request.number }}' > /tmp/pr/number
- name: Upload PR number artifact
uses: actions/upload-artifact@v4
with:
name: pr-number
path: /tmp/pr/number