Skip to content

A local-first personal finance app

[AI] Add workflow to auto-label AI-generated PRs (#7817)

Matiss Janis Aboltinsb61732e20ecc
diff --git a/.github/workflows/ai-generated-label.yml b/.github/workflows/ai-generated-label.yml
new file mode 100644
index 0000000000..f56c529835
--- /dev/null
+++ b/.github/workflows/ai-generated-label.yml
@@ -0,0 +1,27 @@
+name: Add 'AI generated' label to '[AI]' PRs
+
+##########################################################################################
+# This workflow uses the 'pull_request_target' event so it has a token that can add a #
+# label to PRs from forks. It does NOT check out or execute any code from the PR, so it #
+# is not vulnerable to the usual 'pull_request_target' code-injection concerns. Keep it #
+# that way - do not add a checkout step or run any PR-provided scripts here. #
+##########################################################################################
+
+on:
+ # This workflow never checks out or runs PR code; it only reads the PR title and adds a label.
+ pull_request_target: # zizmor: ignore[dangerous-triggers]
+ types: [opened, reopened, edited]
+
+permissions:
+ pull-requests: write
+
+jobs:
+ add-ai-generated-label:
+ name: Add 'AI generated' label
+ runs-on: ubuntu-latest
+ if: startsWith(github.event.pull_request.title, '[AI]')
+ steps:
+ - uses: actions-ecosystem/action-add-labels@bd52874380e3909a1ac983768df6976535ece7f8 # v1.1.0
+ with:
+ labels: AI generated
+ github_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/upcoming-release-notes/7817.md b/upcoming-release-notes/7817.md
new file mode 100644
index 0000000000..cf20b197f9
--- /dev/null
+++ b/upcoming-release-notes/7817.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Add a GitHub Actions workflow that labels `[AI]`-prefixed pull requests as "AI generated".