feat(workflow): Multiple fixes in one (#160)

* fix(workflow): Re-organized the workflow, put the scripts in their own scripts folder

* fix(workflow): Fixed so that we have a default SELECT selection in the issue templates

* fix(workflow): Added a way to run the issue workflows manually as well

* feat(workflow): Added workflow for closing issues with no selected plugin

* fix(workflow): Changed so that we only use one file for jobs that only care about the plugin folders

* fix(workflows): resolve repository root after script move

---------

Co-authored-by: Lemmy <studio@quadbyte.net>
This commit is contained in:
Spyridon Siarapis
2026-07-30 09:17:54 -04:00
committed by GitHub
co-authored by Lemmy
parent 68d904fcea
commit 9b2179899b
15 changed files with 144 additions and 67 deletions
@@ -0,0 +1,37 @@
name: Check for the correct plugin format in issues
on:
issues:
types: [opened]
workflow_dispatch:
inputs:
issue-number:
required: true
type: number
permissions:
contents: read
issues: write
jobs:
check-for-correct-plugin:
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 }}
ISSUE_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.issue-number || github.event.issue.number }}
run: python3 .github/workflows/scripts/issues-check-for-correct-plugin.py
@@ -3,6 +3,11 @@ name: Notify Plugin Authors for Issues
on:
issues:
types: [opened]
workflow_dispatch:
inputs:
issue-number:
required: true
type: number
permissions:
contents: read
@@ -19,14 +24,14 @@ jobs:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: |
.github/workflows/notify-plugin-authors-requirements.txt
.github/workflows/scripts/PyGithub-requirement.txt
- name: Install dependencies
run: pip install -r .github/workflows/notify-plugin-authors-requirements.txt
run: pip install -r .github/workflows/scripts/PyGithub-requirement.txt
- name: Notify Authors
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: python3 .github/workflows/issues-notify-plugin-authors.py
ISSUE_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.issue-number || github.event.issue.number }}
run: python3 .github/workflows/scripts/issues-notify-plugin-authors.py
+9 -4
View File
@@ -3,6 +3,11 @@ name: Update title of issue to represent the plugin
on:
issues:
types: [opened]
workflow_dispatch:
inputs:
issue-number:
required: true
type: number
permissions:
contents: read
@@ -19,15 +24,15 @@ jobs:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: |
.github/workflows/notify-plugin-authors-requirements.txt
.github/workflows/scripts/PyGithub-requirement.txt
- name: Install dependencies
run: pip install -r .github/workflows/notify-plugin-authors-requirements.txt
run: pip install -r .github/workflows/scripts/PyGithub-requirement.txt
- name: Update Issue Title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: python3 .github/workflows/issues-update-title.py
ISSUE_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.issue-number || github.event.issue.number }}
run: python3 .github/workflows/scripts/issues-update-title.py
@@ -1,18 +1,56 @@
name: Update Issue Templates
name: Jobs to run on push to main
on:
push:
branches:
- main
paths-ignore:
- catalog.toml
- '.**'
- README.md
- README_TEMPLATE.md
workflow_dispatch:
concurrency:
group: update-issue-templates-${{ github.ref }}
group: on-push-${{ github.ref }}
cancel-in-progress: true
jobs:
update-catalog:
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ github.repository == 'noctalia-dev/community-plugins' }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Rebuild catalog
run: python3 .github/workflows/scripts/update-catalog.py
- name: Check for changes
id: check_changes
run: |
git add catalog.toml
if git diff --cached --quiet catalog.toml; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes to catalog.toml"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Changes detected in catalog.toml"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "chore: update plugin catalog [skip ci]"
git push
update-issue-templates:
runs-on: ubuntu-latest
permissions:
@@ -26,13 +64,12 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update Issue Templates
run: python3 .github/workflows/update-issue-templates.py
run: python3 .github/workflows/scripts/update-issue-templates.py
- name: Check for changes
id: check_changes
run: |
git add .github/ISSUE_TEMPLATE/bug_report.yml .github/ISSUE_TEMPLATE/feature_request.yml
if git diff --quiet --cached -- .github/ISSUE_TEMPLATE/bug_report.yml && git diff --quiet --cached -- .github/ISSUE_TEMPLATE/feature_request.yml; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes found in the issue templates!"
@@ -0,0 +1,40 @@
import os
import sys
from github import Auth, Github
token = os.environ["GITHUB_TOKEN"]
repo_name = os.environ["REPOSITORY"]
issue_number = os.environ["ISSUE_NUMBER"]
auth = Auth.Token(token)
gh = Github(auth=auth)
repo = gh.get_repo(repo_name)
if issue_number.isdigit():
issue_number = int(issue_number)
else:
print("Issue number is not numeric!")
sys.exit(1)
issue = repo.get_issue(issue_number)
body = issue.body
lines = body.splitlines()
try:
title_index = lines.index("### Plugin")
except ValueError:
print("No Plugin title found!")
sys.exit(0)
for i in range(title_index + 1, len(lines)):
if lines[i]:
break
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')
@@ -9,7 +9,7 @@ import tomllib
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parents[2]
ROOT_DIR = Path(__file__).resolve().parents[3]
CATALOG_PATH = ROOT_DIR / "catalog.toml"
REQUIRED_FIELDS = ("id", "name", "version", "author", "plugin_api", "tags")
OPTIONAL_STRING_FIELDS = ("license", "icon", "description")
@@ -11,9 +11,11 @@ def build_dropdown_component(plugins: list[str]) -> str:
attributes:
label: Plugin
description: The plugin id.
default: 0
options:
- --- SELECT ---
{
"\n".join([f"""\
"".join([f"""\
- {plugin}
""" for plugin in plugins])
}
@@ -12,7 +12,7 @@ from pathlib import Path
from typing import Any
DEFAULT_ROOT = Path(__file__).resolve().parents[2]
DEFAULT_ROOT = Path(__file__).resolve().parents[3]
SEMVER_RE = re.compile(r"^\d+\.\d+\.\d+$")
LAUNCHER_PREFIX_RE = re.compile(r"^[a-z]+$")
DESCRIPTION_MAX_CHARS = 120
-49
View File
@@ -1,49 +0,0 @@
name: Update Plugin Catalog
on:
push:
branches:
- main
paths-ignore:
- catalog.toml
workflow_dispatch:
concurrency:
group: update-plugin-catalog-${{ github.ref }}
cancel-in-progress: true
jobs:
update-catalog:
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ github.repository == 'noctalia-dev/community-plugins' }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Rebuild catalog
run: python3 .github/workflows/update-catalog.py
- name: Check for changes
id: check_changes
run: |
git add catalog.toml
if git diff --cached --quiet catalog.toml; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes to catalog.toml"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Changes detected in catalog.toml"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "chore: update plugin catalog [skip ci]"
git push
+2 -2
View File
@@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v7
- name: Validate plugin manifests
run: python3 .github/workflows/validate-plugins.py
run: python3 .github/workflows/scripts/validate-plugins.py
- name: Test plugin validator
run: python3 -m unittest discover -s .github/workflows -p 'test_*.py'
run: python3 -m unittest discover -s .github/workflows/scripts -p 'test_*.py'