diff --git a/README.md b/README.md index 5709307..a6839fd 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ There are different variables to setup the behaviour: From the repository that this Git Action is executed the directory that contains the files to be pushed into the repository. ### `destination-github-username` (argument) -For the repository `https://github.com/cpina/push-to-another-repository-output` is `cpina`. It's also used for the `Author:` in the generated git messages. +For the repository `https://github.com/cpina/push-to-another-repository-output` is `cpina`. ### `destination-repository-name` (argument) For the repository `https://github.com/cpina/push-to-another-repository-output` is `push-to-another-repository-output` @@ -25,6 +25,9 @@ For the repository `https://github.com/cpina/push-to-another-repository-output` ### `user-email` (argument) The email that will be used for the commit in the destination-repository-name. +### `user-name` (argument) [optional] +The name that will be used for the commit in the destination-repository-name. If not specified, the `destination-github-username` will be used instead. + ### `destination-repository-username` (argument) [optional] The Username/Organization for the destination repository, if different from `destination-github-username`. For the repository `https://github.com/cpina/push-to-another-repository-output` is `cpina`. diff --git a/action.yml b/action.yml index f16b1b1..7501040 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,10 @@ inputs: user-email: description: 'Email for the git commit' required: true + user-name: + description: '[Optional] Name for the git commit. Defaults to the destination username/organization name' + required: false + default: '' destination-repository-username: description: '[Optional] Username/organization for the destination repository' required: false @@ -33,6 +37,7 @@ runs: - ${{ inputs.destination-github-username }} - ${{ inputs.destination-repository-name }} - ${{ inputs.user-email }} + - ${{ inputs.user-name }} - ${{ inputs.destination-repository-username }} - ${{ inputs.target-branch }} - ${{ inputs.commit-message }} diff --git a/entrypoint.sh b/entrypoint.sh index 224f424..e41a175 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,21 +8,27 @@ SOURCE_DIRECTORY="$1" DESTINATION_GITHUB_USERNAME="$2" DESTINATION_REPOSITORY_NAME="$3" USER_EMAIL="$4" -DESTINATION_REPOSITORY_USERNAME="$5" -TARGET_BRANCH="$6" -COMMIT_MESSAGE="$7" +USER_NAME="$5" +DESTINATION_REPOSITORY_USERNAME="$6" +TARGET_BRANCH="$7" +COMMIT_MESSAGE="$8" if [ -z "$DESTINATION_REPOSITORY_USERNAME" ] then DESTINATION_REPOSITORY_USERNAME="$DESTINATION_GITHUB_USERNAME" fi +if [ -z "$USER_NAME" ] +then + USER_NAME="$DESTINATION_GITHUB_USERNAME" +fi + CLONE_DIR=$(mktemp -d) echo "Cloning destination git repository" # Setup git git config --global user.email "$USER_EMAIL" -git config --global user.name "$DESTINATION_GITHUB_USERNAME" +git config --global user.name "$USER_NAME" git clone --single-branch --branch "$TARGET_BRANCH" "https://$API_TOKEN_GITHUB@github.com/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR" ls -la "$CLONE_DIR"