allow "branch" to be derived from "base"
It would be useful to be able to "namespace" generated pull requests to the branch they target.
Consider the case of code generation: I make some code changes, and I want the bots to run the codegen job and open a PR against my changes - and I want this to happen on all branches. This feature would allow me to express that.
Hi @tamird
I'm not sure if I understand this correctly, but do you just want to name PR branches based on the base? If that's the case it should be simple to do in a step before the action runs.
Hi @peter-evans. Maybe there's an obvious and simpler solution, but this is the best I could come up with:
jobs:
example:
runs-on: ubuntu-latest
steps:
- id: determine-target
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "target_branch=${{ github.event.pull_request.base.ref }}" >> $GITHUB_OUTPUT
else # must be push, i guess?
echo "target_branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- uses: peter-evans/create-pull-request@v7
with:
branch: "${{ steps.determine-target.outputs.target_branch }}-feature-branch"
My thinking in filing this issue was that there must already be this kind of logic that can find the base branch independent of the type of trigger, so it would be easier to add this there than to push it to the user.