PR workflow, add labels based on files/branch name

- Add PR labels based on changed files
- Add PR labels based on branch names
This commit is contained in:
Wolfsblvt
2025-03-13 16:33:47 +01:00
parent 4f7695b0ce
commit 84e7ddbf74
4 changed files with 137 additions and 43 deletions

View File

@@ -1,29 +0,0 @@
🏭 Backend Changes:
- "src/**"
- "server.js"
- "plugins.js"
- "recover.js"
- "webpack.config.js"
- "Start.bat"
- "start.sh"
- "UpdateAndStart.bat"
- "UpdateForkAndStart.bat"
🛠️ Build Changes:
- ".github/workflows/**"
- "docker/**"
- ".dockerignore"
- "Dockerfile"
- "webpack.config.js"
🌐 Language:
- "public/locales/**"
📥 Dependencies:
- "public/lib/**" # Every frontend lib counts as a dependency as well
- "package.json"
- "package-lock.json"
- "tests/package.json"
- "tests/package-lock.json"
- "src/electron/package.json"
- "src/electron/package-lock.json"

77
.github/pr-auto-labels-by-branch.yml vendored Normal file
View File

@@ -0,0 +1,77 @@
####################################
# Label PRs against 'release' #
####################################
❗ Against Release Branch:
- base-branch: 'release'
####################################
# Labels based on PR branch name #
####################################
🦋 Bug Fix:
- head-branch: ['^fix[/-]', '\bfixes\b']
🚑 Hot Fix:
- head-branch: ['^hotfix[/-]']
✨ New Feature:
- head-branch: ['^feat(ure)?[/-].*?\badd', '^add-']
✨ Feature Changes:
- head-branch: ['^feat(ure)?[/-](?!.*\badd\b)', '\bchanges?\b']
🤖 API / Model:
- head-branch: ['\bapi\b', '\bmodels?\b']
🏭 Backend Changes:
- head-branch: ['\bbackend\b', '\bendpoints?\b']
🐋 Docker:
- head-branch: ['\bdocker\b']
Extension:
- head-branch: ['\bextension\b', '\bext\b']
🦊 Firefox:
- head-branch: ['\bfirefox\b']
🖼️ Image Gen:
- head-branch: ['\bimage-gen\b']
🌐 Language:
- head-branch: ['\btranslations?\b', '\blanguages?\b']
🐧 Linux:
- head-branch: ['\blinux\b']
🧩 Macros:
- head-branch: ['\bmacros?\b']
📱 Mobile:
- head-branch: ['\bmobile\b', '\bios\b', '\bandroid\b']
🚄 Performance:
- head-branch: ['\bperformance\b']
⚙️ Preset:
- head-branch: ['\bpresets?\b']
📜 Prompt:
- head-branch: ['\bprompt\b']
🚚 Refactor:
- head-branch: ['\brefactor(s|ed)?\b']
📜 STscript:
- head-branch: ['\bstscript\b', '\bslash-commands\b']
🏷️ Tags / Folders:
- head-branch: ['\btags\b']
🎙️ TTS / Voice:
- head-branch: ['\btts\b', '\bvoice\b']
🌟 UX:
- head-branch: ['\bux\b']
🗺️ World Info:
- head-branch: ['\bworld-info\b', '\bwi\b']

40
.github/pr-auto-labels-by-files.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
####################################
# Labels based on changed files #
####################################
🏭 Backend Changes:
- changed-files:
- any-glob-to-any-file:
- "src/**"
- "server.js"
- "plugins.js"
- "recover.js"
- "webpack.config.js"
- "Start.bat"
- "start.sh"
- "UpdateAndStart.bat"
- "UpdateForkAndStart.bat"
🛠️ Build Changes:
- changed-files:
- any-glob-to-any-file:
- ".github/workflows/**"
- "docker/**"
- ".dockerignore"
- "Dockerfile"
- "webpack.config.js"
🌐 Language:
- changed-files:
- any-glob-to-any-file:
- "public/locales/**"
📥 Dependencies:
- changed-files:
- any-glob-to-any-file:
- "public/lib/**" # Every frontend lib counts as a dependency as well
- "package.json"
- "package-lock.json"
- "tests/package.json"
- "tests/package-lock.json"
- "src/electron/package.json"
- "src/electron/package-lock.json"

View File

@@ -20,7 +20,7 @@ jobs:
commentOnDirty: >
⚠️ This PR has conflicts that need to be resolved before it can be merged.
pr-size-labeler:
label-by-size:
name: Apply Label for PR Size
runs-on: ubuntu-latest
@@ -50,19 +50,22 @@ jobs:
"package-lock.json"
"public/lib/*"
label-release-prs:
name: Label PRs Targeting Release Branch
label-by-branches:
name: Apply Labels Based on Branch Name and Target Branch
runs-on: ubuntu-latest
# Only label once when PR is created or branches are changed, to allow manual label removal
if: github.event.action == 'opened' || (github.event.action == 'synchronize' && (github.event.changes.base || github.event.changes.head))
steps:
- name: Label PRs Targeting Release Branch
if: github.base_ref == 'release'
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "❗ Against Release Branch"
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
- name: Apply Labels Based on Branch Name and Target Branch
# Pull Request Labeler
# https://github.com/marketplace/actions/labeler
uses: actions/labeler@v5
with:
configuration-path: .github/pr-auto-labels-by-branch.yml
repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
apply-file-based-labels:
label-by-files:
name: Apply Labels Based on Changed Files
runs-on: ubuntu-latest
@@ -72,11 +75,12 @@ jobs:
# https://github.com/marketplace/actions/labeler
uses: actions/labeler@v5
with:
configuration-path: .github/pr-auto-labels-by-files.yml
repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
check-merge-blocking-labels:
name: Check Merge Blocking Labels
needs: [check-merge-conflicts, pr-size-labeler, label-release-prs, apply-file-based-labels]
needs: [check-merge-conflicts, label-by-size, label-by-branches, label-by-files]
runs-on: ubuntu-latest
steps:
@@ -89,6 +93,7 @@ jobs:
script: |
const prLabels = context.payload.pull_request.labels.map(label => label.name);
const blockingLabels = [
"🚫 Merge Conflicts",
"⛔ Don't Merge",
"🔨 Needs Work",
"🔬 Needs Testing",
@@ -116,9 +121,9 @@ jobs:
console.log("No merge-blocking labels found.");
}
pr-auto-comments:
write-auto-comments:
name: Post PR Comments Based on Labels
needs: [check-merge-conflicts, pr-size-labeler, label-release-prs, apply-file-based-labels]
needs: [check-merge-conflicts, label-by-size, label-by-branches, label-by-files]
runs-on: ubuntu-latest
steps:
@@ -162,7 +167,8 @@ jobs:
ISSUES=$(jq -c -n --argjson a "$issues" --argjson b "$linked_issues" '$a + $b | unique')
echo "final_issues=$ISSUES" >> $GITHUB_ENV
- name: Comment and Label Issues
- name: Label Linked Issues
id: label_linked_issues
env:
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
run: |