feat(workflow): Added the workflow for notifying plugin authors in PR's (#180)

* fix(workflow): Fixed a small bug with the issues-check-for-correct-plugin workflow

* feat(workflow): Added a workflow to notify plugin authors for PR's

* add pull-request: write perm

---------

Co-authored-by: Lemmy <studio@quadbyte.net>
This commit is contained in:
Spyridon Siarapis
2026-07-31 21:35:41 -04:00
committed by GitHub
co-authored by Lemmy
parent 43b8003a71
commit 3c551c7832
3 changed files with 114 additions and 1 deletions
@@ -0,0 +1,43 @@
name: Notify Plugin Authors for Pull Requests
on:
pull_request_target:
types: [opened]
paths-ignore:
- catalog.toml
- '.**'
- README.md
- README_TEMPLATE.md
workflow_dispatch:
inputs:
pull-request-number:
required: true
type: number
permissions:
contents: read
issues: write
pull-requests: write
jobs:
notify-plugin-authors:
runs-on: ubuntu-latest
if: github.repository == 'noctalia-dev/community-plugins'
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: |
.github/workflows/scripts/PyGithub-requirement.txt
- name: Install dependencies
run: pip install -r .github/workflows/scripts/PyGithub-requirement.txt
- name: Notify Authors
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
PULL_REQUEST_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pull-request-number || github.event.pull_request.number }}
run: python3 .github/workflows/scripts/pr-notify-plugin-authors.py
@@ -37,4 +37,4 @@ plugin = lines[i].strip()
if "--- SELECT ---" in plugin:
issue.create_comment("Specify which plugin this issue is about!")
issue.edit(state='closed', state_reason='null')
issue.edit(state='closed')
@@ -0,0 +1,70 @@
import os
import sys
from github import Auth, Github
token = os.environ["GITHUB_TOKEN"]
repo_name = os.environ["REPOSITORY"]
pull_request_number = os.environ["PULL_REQUEST_NUMBER"]
auth = Auth.Token(token)
gh = Github(auth=auth)
repo = gh.get_repo(repo_name)
if pull_request_number.isdigit():
pull_request_number = int(pull_request_number)
else:
print("Pull Request number is not numeric!")
sys.exit(1)
pull_request = repo.get_pull(pull_request_number)
plugin_dirs = set()
hidden_dirs = set()
root_files = set()
for file in pull_request.get_files():
file_split = file.filename.split("/")
if len(file_split) > 1:
root_dir = file_split[0]
if root_dir.startswith('.'):
hidden_dirs.add(root_dir)
else:
plugin_dirs.add(root_dir)
else:
root_files.add(file)
if len(plugin_dirs) > 1:
print("Multiple plugin changes in one PR!")
pull_request.create_issue_comment("This pull request was automatically closed because it contains changes for two or more plugins in one PR!")
pull_request.edit(state='closed')
sys.exit(0)
elif len(plugin_dirs) == 1:
plugin_dir = plugin_dirs.pop()
manifest_file = f"{plugin_dir}/plugin.toml"
if os.path.exists(manifest_file):
file_commits = repo.get_commits(path=manifest_file).reversed
author = file_commits[0].author
if author is not None:
author = author.login
else:
print("Author name is null, returning!")
sys.exit(1)
else:
print(f"Plugin manifest doesn't exist, {manifest_file}")
sys.exit(0)
else:
print("This is a non-plugin change, returning!")
sys.exit(0)
pr_author = pull_request.user.login
if pr_author == author:
print("The author and maintainer of the plugin are the same!")
sys.exit(0)
else:
pull_request.create_issue_comment(f"CC @{author}")