Visitar URL original
[Bug]: when cleaning up PRs with is_pr_cleanup: true, switches to main on PR cleanup · Issue #529 · AndreasAugustin/actions-template-sync · GitHub
Skip to content

[Bug]: when cleaning up PRs with is_pr_cleanup: true, switches to main on PR cleanup #529

Closed

Description

@kanno41

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I had an old PR existing and tried to have it clean up the old PR. However, when it cleaned up the PR, it switched the branch to main. I am using a GitHub App.
template-sync-bug

Expected Behavior

PR should be created from created chore branch

Current Behavior

See Description

Steps To Reproduce

No response

Possible Solution

unsure, theoretically is_keep_branch_on_pr_cleanup: true should work for me, but it is also has a bug (#528)

Additional Information/Context

I am using is_force_push_pr: true. I don't really want to force push, I want to delete the branch first in all cases (which is essentially a force push, I suppose).

Template sync version Version

2.2.0

Activity

  1. AndreasAugustin commented on Jun 5, 2024

    @AndreasAugustin
    Owner

    that is weird. Need to check it. Thanks for the report!

    Update:
    ok, issue seems clear related to docs https://cli.github.com/manual/gh_pr_close
    gh pr close -d is also deleting the local branch. Seems I tried to be smart and failed.. 😸

    Will try to provide a fix asap.

    Remark
    @kanno41 Can you give some more details why you are using is_force_push_pr: true? What is your use case? Actually the action won't push or create a new PR if there are no changes within the remote repository. For the force push you do not need to delete the branch first.

  2. AndreasAugustin commented on Jun 5, 2024

    @AndreasAugustin
    Owner

    @all-contributors please add @kanno41 for bug

  3. allcontributors commented on Jun 5, 2024

    @allcontributors
    Contributor

    @AndreasAugustin

    I've put up a pull request to add @kanno41! 🎉

  4. AndreasAugustin commented on Jun 6, 2024

    @AndreasAugustin
    Owner

    @kanno41 I think I understand the issue now. It is somehow an edge case.

    • You have set is_force_push_pr: true
    • there is already a PR available with the same branch (this happens when you do not have changes within remote repository, when there are changes available, all should be fine because it will create a new branch which is not existing remote yet)
    • the gh pr close -d will delete the local branch because it has the same name like remote

    As a intermediate mitigation action you can remove the is_force_push_pr: true parameter. Then at least the action does not fail anymore.

    For a bug fix I need to think about some options:

    • if is_force_push_pr: true then exclude the current local branch from the deletion list
    • if is_force_push_pr: true and there are no changes within base repo -> remove the -d flag -> when there are changes available in any next run, the branch cleanup will work again
    • some other options

    currently I need to think about the downsides of each option.

  5. added a commit that references this issue on Jun 9, 2024
  6. AndreasAugustin commented on Jun 9, 2024

    @AndreasAugustin
    Owner

    @kanno41 #534 should fix this issue. I need to test it.

    You can try the solution with

          - name: actions-template-sync
            # use here the related branch name
            uses: AndreasAugustin/actions-template-sync@#529
            with:
              source_repo_path: <owner/repo>
              upstream_branch: <target_branch> # defaults to main
              pr_labels: <label1>,<label2>[,...] # defaults to template_sync
              is_force_push_pr: true
              is_pr_cleanup: true

    It actually checks if the remote branch equals the local branch. If so, it skips the cleanup for that branch.

  7. added 3 commits that reference this issue on Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions