github-action-push-to-another-repository icon indicating copy to clipboard operation
github-action-push-to-another-repository copied to clipboard

Does $TARGET_BRANCH cloning work when it doesn't exist on the destination repo?

Open plocket opened this issue 4 years ago • 5 comments

I ran into that problem with my fork - when the $TARGET_BRANCH doesn't exist, cloning fails. Just wanted to give you a head's up in case it's useful.

plocket avatar Dec 14 '20 13:12 plocket

I had to handle it in three places in the end:

  1. When cloning
  2. Checking out the branch by name (when it didn't already exist)
  3. Pushing (which this repo already has)

I also needed a variable to keep track of if it did or didn't exist. See https://github.com/plocket/push-generated-file/blob/master/entrypoint.sh

plocket avatar Dec 15 '20 13:12 plocket

Sorry for the long delay here!

You are 100% right (if the target branch doesn't exist clone fails). I will probably report this to the user instead of creating a new branch automatically but I'll see (I might report it instead of creating a new branch and the reason is that a typo in the TARGET_BRANCH would create a new branch instead of saying to the user that the branch doesn't exist... if it's reported the user would then need to decide what to do: fix the typo or create the branch). Either way your code will help me, thanks!

cpina avatar Apr 25 '21 16:04 cpina

Just to say - I will review this before the next version soon.

cpina avatar Dec 08 '21 23:12 cpina

Hi, I've added fix to that problem: https://github.com/cpina/github-action-push-to-another-repository/pull/49

Wokstym avatar Dec 13 '21 11:12 Wokstym

@Wokstym : I like it, I will give a quick test / probably merge tomorrow before releasing the new version.

Thanks very much for your help, busy days :-)

cpina avatar Dec 13 '21 14:12 cpina

The Action reports the situation correctly. To avoid regressions and too many flags I didn't merge the MR but I would like to say again thanks for submitting it! It might be useful to other people or for future reference.

cpina avatar Sep 05 '22 23:09 cpina