mirror of
https://github.com/izzy2lost/Engine.git
synced 2026-03-10 11:52:02 -07:00
48 lines
1.6 KiB
YAML
48 lines
1.6 KiB
YAML
name: Create Branch from Another Repo
|
|
|
|
on:
|
|
workflow_dispatch: # Allows manual triggering of the workflow
|
|
inputs:
|
|
new_branch_name:
|
|
description: 'Name of the new branch'
|
|
required: true
|
|
source_repo_url:
|
|
description: 'URL of the source repository'
|
|
required: true
|
|
source_branch:
|
|
description: 'Branch name in the source repository'
|
|
required: true
|
|
|
|
jobs:
|
|
create-branch:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout your repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Clone the source repository
|
|
env:
|
|
SOURCE_REPO_TOKEN: ${{ secrets.SOURCE_REPO_TOKEN }}
|
|
run: |
|
|
REPO_URL=${{ github.event.inputs.source_repo_url }}
|
|
CLEANED_URL=${REPO_URL#https://}
|
|
git clone --depth=1 --branch ${{ github.event.inputs.source_branch }} https://$SOURCE_REPO_TOKEN@${CLEANED_URL} source-repo
|
|
|
|
- name: Create new branch and copy changes
|
|
run: |
|
|
cd source-repo
|
|
git checkout -b ${{ github.event.inputs.new_branch_name }}
|
|
cd ..
|
|
mv source-repo/* .
|
|
git add .
|
|
git commit -m "Created branch ${{ github.event.inputs.new_branch_name }} based on ${{ github.event.inputs.source_branch }} from the source repository"
|
|
git branch -M ${{ github.event.inputs.new_branch_name }}
|
|
|
|
- name: Push new branch to your repository
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
git remote add origin https://github.com/${{ github.repository }}
|
|
git push -u origin ${{ github.event.inputs.new_branch_name }}
|