From 198723566f43191eb09ccb82188dd117934f90d1 Mon Sep 17 00:00:00 2001
From: teo <78679830+woosung1223@users.noreply.github.com>
Date: Fri, 29 Dec 2023 22:38:14 +0900
Subject: [PATCH] =?UTF-8?q?feat:=20fork=20=EC=8B=9C=20github=20ID=EC=97=90?=
 =?UTF-8?q?=20=EB=A7=9E=EA=B2=8C=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20=EC=9E=90?=
 =?UTF-8?q?=EB=8F=99=20=EC=83=9D=EC=84=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .github/workflows/add-forked-branch.yml | 45 +++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 .github/workflows/add-forked-branch.yml

diff --git a/.github/workflows/add-forked-branch.yml b/.github/workflows/add-forked-branch.yml
new file mode 100644
index 0000000..9eb0ca8
--- /dev/null
+++ b/.github/workflows/add-forked-branch.yml
@@ -0,0 +1,45 @@
+name: Create Branch on Fork
+
+on:
+  fork:
+    branches:
+      - main
+
+jobs:
+  create-branch:
+    runs-on: ubuntu-latest
+
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v2
+
+    - name: Get forked user's ID
+      id: get-forked-user
+      run: |
+        FORKED_USER=$(curl -s ${GITHUB_API_URL}/repos/${{ github.repository }}/forks | jq -r '.[0].owner.login')
+        echo "Forked user: $FORKED_USER"
+        echo "::set-output name=forked_user::$FORKED_USER"
+      env:
+        GITHUB_API_URL: https://api.github.com
+
+    - name: Create branch on original repository
+      run: |
+        FORKED_USER=${{ steps.get-forked-user.outputs.forked_user }}
+        NEW_BRANCH_NAME="${FORKED_USER}"
+        
+        # Set up Git config
+        git config user.name "GitHub Actions"
+        git config user.email "actions@github.com"
+
+        # Fetch branches from original repository
+        git fetch origin
+        
+        # Create a new branch
+        git checkout -b $NEW_BRANCH_NAME origin/main
+
+        # Push the new branch to the original repository
+        git push origin $NEW_BRANCH_NAME
+
+      env:
+        FORKED_USER: ${{ steps.get-forked-user.outputs.forked_user }}
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}