Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support recursive copy #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ This GitHub Action copies a folder from the current repository to a location in
* destination_base_branch: [optional] The branch into which you want your code merged. Default is `main`.
* destination_head_branch: The branch to create to push the changes. Cannot be `master` or `main`.
* pull_request_reviewers: [optional] The pull request reviewers. It can be only one (just like 'reviewer') or many (just like 'reviewer1,reviewer2,...')
* recursive: [optional] If `true` specified, the source_folder and its entire subtree are copied into destination_folder.


## ENV
* API_TOKEN_GITHUB: You must create a personal access token in you account. Follow the link:
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ inputs:
pull_request_reviewers:
description: 'Pull request reviewers users'
required: false
recursive:
description: 'If `true` specified`, the source_folder and its entire subtree are copied into destination_folder.'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -38,6 +41,7 @@ runs:
- ${{ inputs.destination-head-branch }}
- ${{ inputs.destination-base-branch }}
- ${{ inputs.pull-request-reviewers }}
- ${{ inputs.recursive }}
branding:
icon: 'git-commit'
color: 'green'
color: 'green'
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ else
PULL_REQUEST_REVIEWERS='-r '$INPUT_PULL_REQUEST_REVIEWERS
fi

if [ "$INPUT_RECURSIVE" == "true" ]
then
CP_OPTION="-r"
else
CP_OPTION=""
fi
CLONE_DIR=$(mktemp -d)

echo "Setting git variables"
export API_TOKEN_GITHUB=${API_TOKEN_GITHUB//$'\n'}
export GITHUB_TOKEN=$API_TOKEN_GITHUB
git config --global user.email "$INPUT_USER_EMAIL"
git config --global user.name "$INPUT_USER_NAME"
Expand All @@ -34,7 +41,7 @@ git clone "https://$API_TOKEN_GITHUB@github.com/$INPUT_DESTINATION_REPO.git" "$C

echo "Copying contents to git repo"
mkdir -p $CLONE_DIR/$INPUT_DESTINATION_FOLDER/
cp $INPUT_SOURCE_FOLDER "$CLONE_DIR/$INPUT_DESTINATION_FOLDER/"
cp $CP_OPTION $INPUT_SOURCE_FOLDER "$CLONE_DIR/$INPUT_DESTINATION_FOLDER/"
cd "$CLONE_DIR"
git checkout -b "$INPUT_DESTINATION_HEAD_BRANCH"

Expand Down