Skip to content

Action fails when it is triggered for more than one time from the same branch #113

@sudharshanrao91

Description

@sudharshanrao91

Hi team,
First of all, thank you for this cool github action which simplifies one of our use cases.
Now, let's get to the bug part.

We are using this action to push some code to a target repo. The action works well as expected, except for one scenario:

  1. When we trigger the github action for the first time, with create-target-branch-if-needed set to true, the github action proceeds properly.
  2. When we trigger it again from the same branch/PR (let's say we had some changes that needed to be done on the same PR/branch), create-target-branch-if-needed is already set to true and the action fails with the below error
    fatal: a branch named <branch_name> already exists
  3. This is because of this part of the code , which causes git to fail
  4. As a workaround, we added a condition to check whether the target branch is already present, and dynamically set the create-target-branch-if-needed attribute:
if [ $(git ls-remote --heads https://github.com/xxxx/yyy.git $CURRENT_BRANCH | wc -l ) == 1 ]; then
  echo "CREATE_TARGET_BRANCH=false" >> $GITHUB_ENV
else
   echo "CREATE_TARGET_BRANCH=true" >> $GITHUB_ENV
fi
  1. Could we have some feature that can support this use case.

Apologies, if this already handled and guide me to the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions