From 84e7ddbf743ca9f59d8fca1b0dbeae5c2ae3af1d Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Thu, 13 Mar 2025 16:33:47 +0100 Subject: [PATCH] PR workflow, add labels based on files/branch name - Add PR labels based on changed files - Add PR labels based on branch names --- .github/pr-auto-labels,yml | 29 ---------- .github/pr-auto-labels-by-branch.yml | 77 +++++++++++++++++++++++++++ .github/pr-auto-labels-by-files.yml | 40 ++++++++++++++ .github/workflows/pr-auto-manager.yml | 34 +++++++----- 4 files changed, 137 insertions(+), 43 deletions(-) delete mode 100644 .github/pr-auto-labels,yml create mode 100644 .github/pr-auto-labels-by-branch.yml create mode 100644 .github/pr-auto-labels-by-files.yml diff --git a/.github/pr-auto-labels,yml b/.github/pr-auto-labels,yml deleted file mode 100644 index 1e94c18da..000000000 --- a/.github/pr-auto-labels,yml +++ /dev/null @@ -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" diff --git a/.github/pr-auto-labels-by-branch.yml b/.github/pr-auto-labels-by-branch.yml new file mode 100644 index 000000000..bbb91d760 --- /dev/null +++ b/.github/pr-auto-labels-by-branch.yml @@ -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'] diff --git a/.github/pr-auto-labels-by-files.yml b/.github/pr-auto-labels-by-files.yml new file mode 100644 index 000000000..d20a0a995 --- /dev/null +++ b/.github/pr-auto-labels-by-files.yml @@ -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" diff --git a/.github/workflows/pr-auto-manager.yml b/.github/workflows/pr-auto-manager.yml index 030548c4c..1da762e50 100644 --- a/.github/workflows/pr-auto-manager.yml +++ b/.github/workflows/pr-auto-manager.yml @@ -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: |