From 92277f3abbdaf566dffb7b9b3ea11b423d766da2 Mon Sep 17 00:00:00 2001 From: GuillaumeFalourd Date: Thu, 6 Jan 2022 23:41:45 -0300 Subject: [PATCH 1/3] update git push to remote action Signed-off-by: GuillaumeFalourd --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ee33527..8b4d6ed 100644 --- a/action.yml +++ b/action.yml @@ -91,7 +91,7 @@ runs: git branch push-and-commit-action-${{ github.run_id }}-${{ github.job }} git fetch "${{ inputs.remote_repository }}" "$CURRENT_BRANCH" git checkout "$CURRENT_BRANCH" - git merge push-and-commit-action-${{ github.run_id }}-${{ github.job }} + git merge -X ours push-and-commit-action-${{ github.run_id }}-${{ github.job }} git branch -d push-and-commit-action-${{ github.run_id }}-${{ github.job }} git push "${{ inputs.remote_repository }}" "$CURRENT_BRANCH:$TARGET_BRANCH" --follow-tags $FORCE $TAGS From e7a4b74c2ae71596a2077f6f74d9be93cc176de4 Mon Sep 17 00:00:00 2001 From: GuillaumeFalourd Date: Thu, 6 Jan 2022 23:45:30 -0300 Subject: [PATCH 2/3] update creating branch section Signed-off-by: GuillaumeFalourd --- action.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 8b4d6ed..c312da4 100644 --- a/action.yml +++ b/action.yml @@ -91,7 +91,7 @@ runs: git branch push-and-commit-action-${{ github.run_id }}-${{ github.job }} git fetch "${{ inputs.remote_repository }}" "$CURRENT_BRANCH" git checkout "$CURRENT_BRANCH" - git merge -X ours push-and-commit-action-${{ github.run_id }}-${{ github.job }} + git merge push-and-commit-action-${{ github.run_id }}-${{ github.job }} git branch -d push-and-commit-action-${{ github.run_id }}-${{ github.job }} git push "${{ inputs.remote_repository }}" "$CURRENT_BRANCH:$TARGET_BRANCH" --follow-tags $FORCE $TAGS @@ -134,10 +134,21 @@ runs: cd "$CLONE_DIRECTORY" - # Create new branch - REMOTE_URL=https://$DESTINATION_OWNER:${{ inputs.access_token }}@github.com/$DESTINATION_OWNER/$DESTINATION_REPOSITORY + REMOTE_URL=https://$DESTINATION_OWNER:${{ inputs.access_token }}@github.com/$DESTINATION_OWNER/$DESTINATION_REPOSITORY git remote set-url origin $REMOTE_URL git fetch origin + + if [ -z "${{ inputs.target_dir }}" ]; then + git add ${{ inputs.source_files }} + else + git add ${{ inputs.target_dir }}/${{ inputs.source_files }} + fi + # Won't commit if no changes were made + git diff-index --quiet HEAD || git commit --message "${{ inputs.commit_message }}" + git status + git branch copy-push-files-action-${{ github.run_id }}-${{ github.job }} + + # Create new branch (if necessary) BE=$(git ls-remote --heads origin ${{ inputs.target_branch }} | wc -l) if [[ $BE == *"0"* ]]; then echo "##### Target branch doesn't exist. Creating new branch #####" @@ -145,15 +156,11 @@ runs: else git checkout ${{ inputs.target_branch }} fi - git add . - git status - - # Won't commit if no changes were made - git diff-index --quiet HEAD || git commit --message "${{ inputs.commit_message }}" + git merge -X theirs copy-push-files-action-${{ github.run_id }}-${{ github.job }} + git branch -d copy-push-files-action-${{ github.run_id }}-${{ github.job }} echo echo "##### Pushing git commit #####" - # --set-upstream: sets the branch when pushing to a branch that does not exist git push -f -u origin "${{ inputs.target_branch }}" else From c80328cf2744d6a89eb7fd42f00f5832cc942de3 Mon Sep 17 00:00:00 2001 From: GuillaumeFalourd Date: Thu, 6 Jan 2022 23:50:46 -0300 Subject: [PATCH 3/3] update creating branch section Signed-off-by: GuillaumeFalourd --- action.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index c312da4..ac06b9f 100644 --- a/action.yml +++ b/action.yml @@ -134,15 +134,12 @@ runs: cd "$CLONE_DIRECTORY" - REMOTE_URL=https://$DESTINATION_OWNER:${{ inputs.access_token }}@github.com/$DESTINATION_OWNER/$DESTINATION_REPOSITORY + REMOTE_URL=https://$DESTINATION_OWNER:${{ inputs.access_token }}@github.com/$DESTINATION_OWNER/$DESTINATION_REPOSITORY git remote set-url origin $REMOTE_URL git fetch origin - if [ -z "${{ inputs.target_dir }}" ]; then - git add ${{ inputs.source_files }} - else - git add ${{ inputs.target_dir }}/${{ inputs.source_files }} - fi + git add ${{ inputs.files }} + # Won't commit if no changes were made git diff-index --quiet HEAD || git commit --message "${{ inputs.commit_message }}" git status