You've already forked devops-pipeline-template
41 lines
1.2 KiB
YAML
41 lines
1.2 KiB
YAML
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
|
|
|