ci: update auto assign workflow

Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
Andy Lee 2026-03-24 14:28:51 +08:00
parent 9a8a709e56
commit f3c442f0ea
No known key found for this signature in database
GPG Key ID: 39DC4436AE3564D5
4 changed files with 80 additions and 18 deletions

View File

@ -1,6 +1,5 @@
addAssignees: author addAssignees: author
addReviewers: true addReviewers: true
numberOfReviewers: 0
reviewers: reviewers:
- a110605 - a110605
- houhoucoop - houhoucoop

View File

@ -1,17 +0,0 @@
name: "[PR Management] Auto Assign Reviewer & Assignee"
on:
pull_request_target:
types: [opened, ready_for_review]
permissions:
pull-requests: write
jobs:
auto-assign:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: rancher/gh-issue-mgr/auto-assign-action@main
with:
configuration-path: .github/auto-assign-config.yaml

View File

@ -0,0 +1,55 @@
name: "PR Management Auto Assign"
on:
workflow_run:
workflows: ["PR Management Auto Assign Collect Data"]
types: [completed]
env:
REPO_NAME: harvester/harvester-ui-extension
jobs:
auto-assign:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
actions: read
pull-requests: write
steps:
- name: Download PR data artifact
uses: actions/download-artifact@v4
with:
name: pr-auto-assign-data
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
- name: Load PR data
run: |
cat pr-auto-assign-data.env >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Auto assign based on config
env:
GH_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
run: |
# Read config
ADD_ASSIGNEES=$(yq e '.addAssignees' .github/auto-assign-config.yaml)
ADD_REVIEWERS=$(yq e '.addReviewers' .github/auto-assign-config.yaml)
REVIEWERS=$(yq e '.reviewers[]' .github/auto-assign-config.yaml 2>/dev/null || true)
# Assign author if addAssignees is 'author'
if [[ "$ADD_ASSIGNEES" == "author" ]]; then
echo "Assigning PR author: $PR_AUTHOR"
gh pr edit "$PR_NUMBER" --repo "${REPO_NAME}" --add-assignee "$PR_AUTHOR"
fi
# Add reviewers if addReviewers is true and reviewers list is non-empty
if [[ "$ADD_REVIEWERS" == "true" && -n "$REVIEWERS" ]]; then
SELECTED=$(echo "$REVIEWERS" | xargs)
echo "Adding reviewers: $SELECTED"
for reviewer in $SELECTED; do
gh pr edit "$PR_NUMBER" --repo "${REPO_NAME}" --add-reviewer "$reviewer"
done
fi

View File

@ -0,0 +1,25 @@
name: "PR Management Auto Assign Collect Data"
on:
pull_request:
types: [opened, ready_for_review]
jobs:
collect:
runs-on: ubuntu-latest
permissions:
actions: write
pull-requests: read
steps:
- name: Save PR data to artifact
run: |
{
echo "PR_NUMBER=${{ github.event.pull_request.number }}"
echo "PR_AUTHOR=${{ github.event.pull_request.user.login }}"
} > pr-auto-assign-data.env
- name: Upload PR data artifact
uses: actions/upload-artifact@v4
with:
name: pr-auto-assign-data
path: pr-auto-assign-data.env