[llvm] [workflows] Delete user branches that are too long (PR #82845)
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 15:54:44 PST 2024
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/82845
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
>From 8da18496baa7202588cd1a505c9898136ebce5e8 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 23 Feb 2024 23:11:29 +0000
Subject: [PATCH] [workflows] Delete user branches that are too long
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
---
.github/workflows/user-branch-rules.yml | 33 +++++++++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 .github/workflows/user-branch-rules.yml
diff --git a/.github/workflows/user-branch-rules.yml b/.github/workflows/user-branch-rules.yml
new file mode 100644
index 000000000000000..ec96d7490cf6aa5
--- /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
More information about the llvm-commits
mailing list