From e7c2dfb82e248f82c7b5b4733a9c214fa627bbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Tanr=C4=B1verdi?= Date: Tue, 23 Dec 2025 10:56:46 +0300 Subject: [PATCH] first commit --- .gitea/workflows/issue-branch-management.yml | 52 ++++++++++++++++++++ README.md | 0 2 files changed, 52 insertions(+) create mode 100644 .gitea/workflows/issue-branch-management.yml create mode 100644 README.md diff --git a/.gitea/workflows/issue-branch-management.yml b/.gitea/workflows/issue-branch-management.yml new file mode 100644 index 0000000..9d2e0d5 --- /dev/null +++ b/.gitea/workflows/issue-branch-management.yml @@ -0,0 +1,52 @@ +name: Issue Branch Management (Template) + +on: + workflow_call: + secrets: + GITHUB_TOKEN: + required: true + +jobs: + manage-branch: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create branch on issue open or reopen + if: github.event.action == 'opened' || github.event.action == 'reopened' + run: | + ISSUE_NUMBER=${{ github.event.issue.number }} + ISSUE_TITLE="${{ github.event.issue.title }}" + + BRANCH_NAME="issue-${ISSUE_NUMBER}-$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd '[:alnum:]-' | head -c 50)" + + echo "Creating branch: $BRANCH_NAME" + + git config user.name "gitea-actions[bot]" + git config user.email "gitea-actions[bot]@gitea" + + if git ls-remote --exit-code --heads origin "$BRANCH_NAME" > /dev/null 2>&1; then + echo "Branch already exists: $BRANCH_NAME" + else + git checkout -b "$BRANCH_NAME" + git push origin "$BRANCH_NAME" + echo "Branch created: $BRANCH_NAME" + fi + + - name: Delete branch on issue close + if: github.event.action == 'closed' + run: | + ISSUE_NUMBER=${{ github.event.issue.number }} + + echo "Searching branches for issue-${ISSUE_NUMBER}-*" + + for branch in $(git ls-remote --heads origin | grep "refs/heads/issue-${ISSUE_NUMBER}-" | awk '{print $2}' | sed 's|refs/heads/||'); do + echo "Deleting branch: $branch" + git push origin --delete "$branch" || echo "Failed to delete $branch" + done + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29