commit e7c2dfb82e248f82c7b5b4733a9c214fa627bbe8 Author: Burak Tanrıverdi Date: Tue Dec 23 10:56:46 2025 +0300 first commit 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