github-action-push-to-another-repository
github-action-push-to-another-repository copied to clipboard
Does $TARGET_BRANCH cloning work when it doesn't exist on the destination repo?
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.
I had to handle it in three places in the end:
- When cloning
- Checking out the branch by name (when it didn't already exist)
- 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
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!
Just to say - I will review this before the next version soon.
Hi, I've added fix to that problem: https://github.com/cpina/github-action-push-to-another-repository/pull/49
@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 :-)
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.