Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/create-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Create Branch

on:
workflow_dispatch:
inputs:
name:
description: 'Name of the branch to create'
required: true
type: string

permissions:
contents: write

jobs:
create-branch:
name: Create and Push Branch
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Create and push branch
run: |
BRANCH_NAME="${{ github.event.inputs.name }}"

echo "Creating branch: $BRANCH_NAME"

# Check if branch already exists remotely
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
echo "Error: Branch '$BRANCH_NAME' already exists remotely"
exit 1
fi

# Create and checkout new branch
git checkout -b "$BRANCH_NAME"

# Push the new branch to remote
git push origin "$BRANCH_NAME"

echo "Successfully created and pushed branch: $BRANCH_NAME"

- name: Summary
run: |
BRANCH_NAME="${{ github.event.inputs.name }}"
{
echo "## Branch Created Successfully"
echo "- **Branch Name**: \`$BRANCH_NAME\`"
echo "- **URL**: [View Branch](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/$BRANCH_NAME)"
} >> "$GITHUB_STEP_SUMMARY"