Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Add target branch as parameter for creating PR #592

Open
1 task
ambrosekwok opened this issue Jan 5, 2025 · 4 comments
Open
1 task

[Feat]: Add target branch as parameter for creating PR #592

ambrosekwok opened this issue Jan 5, 2025 · 4 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@ambrosekwok
Copy link

Describe the feature

Add target merge branch option as parameter to the action.
Currently, it is same as upstream_branch

Use Case

I think the downstream repository may want to use main branch in the template repository, but prefer different branch like develop for creating the PR.

Proposed Solution

No response

Acknowledgements

  • I may be able to implement this feature request
@AndreasAugustin
Copy link
Owner

AndreasAugustin commented Jan 5, 2025

Hi @ambrosekwok and thanks for the suggestion.
There is actually already a parameter pr_branch_name_prefix available..
Isn't that parameter the one you are looking for?

Initially missunderstood your request.
The target branch is currently always the default branch.

Will think about the suggestion.

@WolfGreyDev
Copy link

I have got around this by using matrix's, however, if you want to target a specific branch for a single run, you cant totally do that too. In the following, I've added the branch name after the repo to checkout that branch only.

steps:
  - name: Checkout ${{ github.repository }} ${{ matrix.branch }}
    uses: actions/checkout@v4
    with:
      ref: ${{ matrix.branch }}
      token: ${{ secrets.PAT }}

As I said earlier, I'm using a matrix to target two branches, so my strategy looks like the following:

strategy:
  matrix:
    branch: [main, beta]

@AndreasAugustin
Copy link
Owner

Hi @WolfGreyDev thanks for your workaround. Possibly this is the solution because you actually need to use the actions/checkout action your mentioned way or it won't pull the right branch (it is using the default branch per default).

Need to double check how to go on, but possibly a short documentation addon is sufficient.

Remark
Using a matrix like you did can possibly lead to issues if you have the same git hash in both branches (not super likely but possible).
You can add the mentioned parameter pr_branch_name_prefix, e.g. pr_branch_name_prefix: ${{matrix.branch}}

@AndreasAugustin AndreasAugustin added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 7, 2025
@WolfGreyDev
Copy link

That's right. Using the following sync settings:

- name: ${{ matrix.settings.name }}
  uses: AndreasAugustin/actions-template-sync@v2
  if: github.repository != env.SOURCE_REPOSITORY
  with:
    source_repo_path: ${{ env.SOURCE_REPOSITORY }}
    upstream_branch: ${{ matrix.branch }}
    pr_branch_name_prefix: ${{ matrix.branch }}_${{ matrix.settings.name }}
    pr_title: "[${{ matrix.branch }}] [${{ matrix.settings.name }}] ${{ matrix.settings.pr_title }}"
    pr_commit_msg: ${{ matrix.settings.pr_message }}
    pr_labels: ${{ matrix.settings.name }}
    git_remote_pull_params: ${{ matrix.branch }} ${{ matrix.settings.pull_params }}
    template_sync_ignore_file_path: .${{ matrix.settings.name }}-ignore

Obviously this has an additional matrix (settings) as I need different pull_params for different files/folders but it should be able to give others an idea of how to set this up. With the addition of the template_sync_ignore_file_path, this is all possible now. Though I still haven't found a solution to remove files that have been removed from the original repo, but that's another separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants