Skip to content

4. Create Data Only Branch for FrEDI #2

4. Create Data Only Branch for FrEDI

4. Create Data Only Branch for FrEDI #2

# https://itecnote.com/tecnote/git-create-a-new-branch-with-only-a-specified-directory-and-its-history-then-push-to-new-repository/
## Create a new branch iwth just one specified directory
name: Create Data Only Branch
on:
workflow_dispatch:
inputs:
branch_name:
type: string
description: Type suffix to your branch name data_only_branch_*
jobs:
get_data:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Commit new branch
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git config --global --add --bool push.autoSetupRemote true
git symbolic-ref HEAD refs/heads/data_only_branch_${{ github.event.inputs.branch_name }}
rm .git/index
git clean -fdx
git checkout ${GITHUB_REF##*/} ./data
git add ./data/*
git commit -am "creating data only branch on data_only_branch_${{ github.event.inputs.branch_name }}"
git fetch origin
git branch -a
ls -a
git push origin data_only_branch_${{ github.event.inputs.branch_name }}