mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
name: 🎯 Issues/PRs Open Handler
|
|
|
|
on:
|
|
issues:
|
|
types: [opened]
|
|
pull_request_target:
|
|
types: [opened]
|
|
|
|
jobs:
|
|
label-maintainer:
|
|
name: Label if Author is a Repo Maintainer
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Label if Author is a Repo Maintainer
|
|
# GitHub Script
|
|
# https://github.com/marketplace/actions/github-script
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
// Get basic info
|
|
const { owner, repo } = context.repo;
|
|
const payload = context.payload;
|
|
// Determine if it's an issue or a pull request
|
|
const eventData = payload.issue || payload.pull_request;
|
|
const username = eventData.user.login;
|
|
const issue_number = eventData.number;
|
|
|
|
// Get the collaborator permission level for the user
|
|
const { data: permissionData } = await github.repos.getCollaboratorPermissionLevel({
|
|
owner,
|
|
repo,
|
|
username,
|
|
});
|
|
|
|
const permission = permissionData.permission;
|
|
console.log(`User ${username} has permission level: ${permission}`);
|
|
|
|
// Check if user is an admin or has maintain permissions
|
|
if (['admin', 'maintain'].includes(permission)) {
|
|
console.log(`Adding "Maintainer" label to issue/PR #${issue_number}`);
|
|
await github.issues.addLabels({
|
|
owner,
|
|
repo,
|
|
issue_number,
|
|
labels: ['👷 Maintainer'],
|
|
});
|
|
} else {
|
|
console.log(`User ${username} is not a repo maintainer.`);
|
|
}
|