[llvm] [workflows] Delete user branches that are too long (PR #82845)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 15:55:16 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-github-workflow

Author: Tom Stellard (tstellar)

<details>
<summary>Changes</summary>

Long branch names can cause problems with git checkouts on Windows See https://discourse.llvm.org/t/user-created-branches-in-the-monorepo-are-often-misused/75544/34

---
Full diff: https://github.com/llvm/llvm-project/pull/82845.diff


1 Files Affected:

- (added) .github/workflows/user-branch-rules.yml (+33) 


``````````diff
diff --git a/.github/workflows/user-branch-rules.yml b/.github/workflows/user-branch-rules.yml
new file mode 100644
index 00000000000000..ec96d7490cf6aa
--- /dev/null
+++ b/.github/workflows/user-branch-rules.yml
@@ -0,0 +1,33 @@
+name: User Branch Rules
+
+permissions:
+  contents: read
+
+
+on:
+  push:
+    branches:
+      - 'users/**'
+
+
+jobs:
+  user-branch-rules:
+    if: github.repository_owner == 'llvm'
+    permissions:
+      contents: write
+    runs-on: ubuntu-latest
+    steps:
+      - name: Check branch length
+        env:
+          GITHUB_TOKEN: ${{ github.token }}
+          MAX_BRANCH_LENGTH: 200
+
+        run: |
+          if [ `echo "$GITHUB_REF" | wc -c` -gt "$MAX_BRANCH_LENGTH" ]; then
+            curl -s -X DELETE \
+                    -H "Accept: application/vnd.github+json" \
+                    -H "Authorization: Bearer $GITHUB_TOKEN" \
+                    -H "X-GitHub-Api-Version: 2022-11-28" \
+                    "https://api.github.com/repos/$GITHUB_REPOSITORY/git/$GITHUB_REF"
+            echo "Branch $GITHUB_REF deleted"
+          fi

``````````

</details>


https://github.com/llvm/llvm-project/pull/82845


More information about the llvm-commits mailing list