Skip to content

feat(ssh-sessions): add panel search and keyboard navigation #438

feat(ssh-sessions): add panel search and keyboard navigation

feat(ssh-sessions): add panel search and keyboard navigation #438

name: Auto-assign Plugin Reviewers
on:
pull_request_target:
types: [opened]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
assign-reviewers:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get changed files and assign reviewers
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
REPO: ${{ github.repository }}
run: |
# Get the list of changed files in this PR
changed_files=$(gh pr view $PR_NUMBER --json files --jq '.files[].path')
# Extract unique top-level directories from changed files
declare -A plugin_dirs
while IFS= read -r file; do
# Extract the first directory component (plugin name)
if [[ "$file" =~ ^([^/]+)/ ]]; then
plugin_dir="${BASH_REMATCH[1]}"
# Skip non-plugin directories
case "$plugin_dir" in
.git|.github|Bin) continue ;;
esac
plugin_dirs["$plugin_dir"]=1
fi
done <<< "$changed_files"
# For each modified plugin, find the original author
declare -A authors
for plugin in "${!plugin_dirs[@]}"; do
echo "Processing plugin: $plugin"
# Get the first commit author for this plugin
commit_sha=$(git log --diff-filter=A --format='%H' --reverse -- "$plugin/" 2>/dev/null | head -n 1)
if [[ -z "$commit_sha" ]]; then
commit_sha=$(git log --format='%H' --reverse -- "$plugin/" 2>/dev/null | head -n 1)
fi
if [[ -z "$commit_sha" ]]; then
echo "No commits found for $plugin"
continue
fi
# Get GitHub username via API
api_url="https://api.github.com/repos/$REPO/commits/$commit_sha"
response=$(gh api "$api_url" 2>/dev/null || echo "")
if [[ -z "$response" ]]; then
echo "Could not fetch commit info from GitHub API"
continue
fi
author=$(echo "$response" | jq -r '.author.login // empty')
if [[ -n "$author" ]]; then
if [[ "$author" == "$PR_AUTHOR" ]]; then
echo "Skipping notification for @$author (PR author)"
else
echo "Found author for $plugin: @$author"
authors["$author"]=1
fi
fi
done
# If we found any authors, notify them
if [[ ${#authors[@]} -eq 0 ]]; then
echo "No plugin authors found"
exit 0
fi
# Build the list of authors
author_list=(${!authors[@]})
author_mentions=$(printf '@%s ' "${author_list[@]}")
# Post appropriate comment based on number of plugins
comment_body=""
if [[ ${#plugin_dirs[@]} -eq 1 ]]; then
comment_body="${author_mentions}- this PR modifies your plugin. Please review when you have a chance."
else
comment_body="${author_mentions}- this PR modifies your plugins. Please review when you have a chance."
fi
# Post comment using gh CLI
gh pr comment "$PR_NUMBER" --body "$comment_body"