From c3f0aa4db9e5f583937038696908d4403942d38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jo=C5=84ski?= Date: Thu, 24 Jun 2021 08:57:24 +0200 Subject: [PATCH 1/6] Add github-server input parameter --- action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/action.yml b/action.yml index 7501040..bd1263c 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,11 @@ inputs: description: '[Optional] commit message for the output repository. ORIGIN_COMMIT is replaced by the URL@commit in the origin repo' default: 'Update from ORIGIN_COMMIT' required: false + github-server: + description: 'Github server' + default: 'github.com' + required: true + runs: using: 'docker' image: 'Dockerfile' @@ -41,6 +46,7 @@ runs: - ${{ inputs.destination-repository-username }} - ${{ inputs.target-branch }} - ${{ inputs.commit-message }} + - ${{ inputs.github-server }} branding: icon: 'git-commit' color: 'green' From 280163351fecf300779567d331efa9fbdfc28ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jo=C5=84ski?= Date: Thu, 24 Jun 2021 08:59:20 +0200 Subject: [PATCH 2/6] Update entrypoint.sh --- entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4e46c3e..378c9d6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,6 +12,7 @@ USER_NAME="$5" DESTINATION_REPOSITORY_USERNAME="$6" TARGET_BRANCH="$7" COMMIT_MESSAGE="$8" +GITHUB_SERVER="$9" if [ -z "$DESTINATION_REPOSITORY_USERNAME" ] then @@ -29,7 +30,7 @@ echo "Cloning destination git repository" # Setup git git config --global user.email "$USER_EMAIL" git config --global user.name "$USER_NAME" -git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@github.com/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR" +git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR" ls -la "$CLONE_DIR" TARGET_DIR=$(mktemp -d) @@ -59,7 +60,7 @@ cd "$TARGET_DIR" echo "Files that will be pushed:" ls -la -ORIGIN_COMMIT="https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" +ORIGIN_COMMIT="https://$GITHUB_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" COMMIT_MESSAGE="${COMMIT_MESSAGE/ORIGIN_COMMIT/$ORIGIN_COMMIT}" COMMIT_MESSAGE="${COMMIT_MESSAGE/\$GITHUB_REF/$GITHUB_REF}" @@ -75,4 +76,4 @@ git diff-index --quiet HEAD || git commit --message "$COMMIT_MESSAGE" echo "git push origin:" # --set-upstream: sets de branch when pushing to a branch that does not exist -git push "https://$USER_NAME:$API_TOKEN_GITHUB@github.com/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" --set-upstream "$TARGET_BRANCH" +git push "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" --set-upstream "$TARGET_BRANCH" From 69e1f423c89167489dba07f8f42bc45ee18f3fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jo=C5=84ski?= Date: Thu, 24 Jun 2021 09:00:26 +0200 Subject: [PATCH 3/6] Update action.yml --- action.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index bd1263c..ad2c949 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,10 @@ inputs: destination-repository-name: description: 'Destination repository' required: true + github-server: + description: 'Github server' + default: 'github.com' + required: true user-email: description: 'Email for the git commit' required: true @@ -29,10 +33,6 @@ inputs: description: '[Optional] commit message for the output repository. ORIGIN_COMMIT is replaced by the URL@commit in the origin repo' default: 'Update from ORIGIN_COMMIT' required: false - github-server: - description: 'Github server' - default: 'github.com' - required: true runs: using: 'docker' @@ -41,12 +41,13 @@ runs: - ${{ inputs.source-directory }} - ${{ inputs.destination-github-username }} - ${{ inputs.destination-repository-name }} + - ${{ inputs.github-server }} - ${{ inputs.user-email }} - ${{ inputs.user-name }} - ${{ inputs.destination-repository-username }} - ${{ inputs.target-branch }} - ${{ inputs.commit-message }} - - ${{ inputs.github-server }} + branding: icon: 'git-commit' color: 'green' From 84dc6cc0706731b787b4e152f7581638d298e216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jo=C5=84ski?= Date: Thu, 24 Jun 2021 09:00:58 +0200 Subject: [PATCH 4/6] Update entrypoint.sh --- entrypoint.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 378c9d6..794a5d1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,12 +7,13 @@ echo "Starts" SOURCE_DIRECTORY="$1" DESTINATION_GITHUB_USERNAME="$2" DESTINATION_REPOSITORY_NAME="$3" -USER_EMAIL="$4" -USER_NAME="$5" -DESTINATION_REPOSITORY_USERNAME="$6" -TARGET_BRANCH="$7" -COMMIT_MESSAGE="$8" -GITHUB_SERVER="$9" +GITHUB_SERVER="$4" +USER_EMAIL="$5" +USER_NAME="$6" +DESTINATION_REPOSITORY_USERNAME="$7" +TARGET_BRANCH="$8" +COMMIT_MESSAGE="$9" + if [ -z "$DESTINATION_REPOSITORY_USERNAME" ] then From 9ed2368a019056b65eaa1a3231aaede6bd2d0ab6 Mon Sep 17 00:00:00 2001 From: Carles Pina i Estany Date: Mon, 25 Oct 2021 23:31:41 +0100 Subject: [PATCH 5/6] server is not required (default was already set) --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ad2c949..f9fede9 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ inputs: github-server: description: 'Github server' default: 'github.com' - required: true + required: false user-email: description: 'Email for the git commit' required: true From f7a5c6e388e448731ed466f1aaca170b7471e910 Mon Sep 17 00:00:00 2001 From: Carles Pina i Estany Date: Mon, 25 Oct 2021 23:32:18 +0100 Subject: [PATCH 6/6] Change the order (all the required and then all the optionals) --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index f9fede9..6565b5e 100644 --- a/action.yml +++ b/action.yml @@ -10,13 +10,13 @@ inputs: destination-repository-name: description: 'Destination repository' required: true + user-email: + description: 'Email for the git commit' + required: true github-server: description: 'Github server' default: 'github.com' required: false - 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