How do I use the create-pull-request GitHub Action to automatically create a PR from my current branch to master?
I have the following workflow and I want to use GitHub Actions to make sure I'm tracking all release changes to master.
[bugfix/some-bug] -> PR -> Merge -> [release/v1.2.3] -> autogen PR to [master]
At the end, I would like a PR to be present in GitHub that is the following:
[master] <- [release/v1.2.3]
Autogenerated by Github Actions.
Mergeback of Release to ensure changes are persisted in Master.
I'm using the following action and actions file which will only trigger once a release/* branch has been merged into.
https://github.com/peter-evans/create-pull-request
on:
push:
branches:
- release/*
jobs:
build:
runs-on: self-hosted
steps:
- name: Extract Branch
shell: bash
id: extract_branch
run: |
echo "::set-output name=branch_type::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\/.*//')"
echo "::set-output name=branch_name::$(echo ${GITHUB_REF#refs/heads/} | sed 's/.*\///')"
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: peter-evans/create-pull-request@v4
with:
commit-message: Mergeback of Release ${{ steps.extract_branch.outputs.branch_name }}
title: Mergeback of Release ${{ steps.extract_branch.outputs.branch_name }}
branch: ${{ steps.extract_branch.outputs.branch_type }}/${{ steps.extract_branch.outputs.branch_name }}
base: master
body: |
Autogenerated by Github Actions.
Mergeback of Release ${{ steps.extract_branch.outputs.branch_name }} to ensure changes are persisted in Master.
The issue is this plugin takes a really strange journey in creating the PR. The following actions log shows the plugin checking out the branch, identifying the 11 changes, resetting the branch to master, and then declaring the branches no longer differ leading to no PR being created.
Create or update the pull request branch
/usr/bin/git symbolic-ref HEAD --short
release/v1.2.3
Working base is branch 'release/v1.2.3'
/usr/bin/git checkout --progress -B a8b75703-b510-4ced-9486-6b504883b514 HEAD --
Switched to a new branch 'a8b75703-b510-4ced-9486-6b504883b514'
/usr/bin/git status --porcelain -unormal --
/usr/bin/git diff --quiet --
/usr/bin/git diff --quiet --staged --
/usr/bin/git reset --hard
HEAD is now at b574c22 actions
/usr/bin/git clean -f -d
Resetting working base branch 'release/v1.2.3'
/usr/bin/git checkout --progress release/v1.2.3 --
Switched to branch 'release/v1.2.3'
Your branch is up to date with 'origin/release/v1.2.3'.
/usr/bin/git reset --hard origin/release/v1.2.3
HEAD is now at b574c22 actions
Rebasing commits made to branch 'release/v1.2.3' on to base branch 'master'
/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --unshallow --force origin master:master
...
From https://github.com/myorg/myrepo
* [new branch] master -> master
* [new branch] master -> origin/master
/usr/bin/git checkout --progress master --
Switched to branch 'master'
/usr/bin/git rev-list --reverse release/v1.2.3..a8b75703-b510-4ced-9486-6b504883b514 .
/usr/bin/git checkout --progress -B a8b75703-b510-4ced-9486-6b504883b514 HEAD --
Switched to and reset branch 'a8b75703-b510-4ced-9486-6b504883b514'
/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force origin master:master
/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force origin release/v1.2.3:refs/remotes/origin/release/v1.2.3
Pull request branch 'release/v1.2.3' already exists as remote branch 'origin/release/v1.2.3'
/usr/bin/git checkout --progress release/v1.2.3 --
Switched to branch 'release/v1.2.3'
Your branch is up to date with 'origin/release/v1.2.3'.
/usr/bin/git diff --quiet release/v1.2.3..a8b75703-b510-4ced-9486-6b504883b514
Resetting 'release/v1.2.3'
/usr/bin/git checkout --progress -B release/v1.2.3 a8b75703-b510-4ced-9486-6b504883b514 --
Reset branch 'release/v1.2.3'
Your branch is behind 'origin/release/v1.2.3' by 11 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
/usr/bin/git rev-list --right-only --count origin/release/v1.2.3...release/v1.2.3
0
/usr/bin/git rev-list --left-only --count origin/release/v1.2.3...release/v1.2.3
11
Updated branch 'release/v1.2.3'
/usr/bin/git rev-list --right-only --count master...release/v1.2.3
0
/usr/bin/git rev-parse HEAD
4f4725ec39b24045ec08d2af4a717740a2669139
/usr/bin/git branch --delete --force a8b75703-b510-4ced-9486-6b504883b514
Deleted branch a8b75703-b510-4ced-9486-6b504883b514 (was 4f4725ec).
Pushing pull request branch to 'origin/release/v1.2.3'
/usr/bin/git push --force-with-lease origin HEAD:refs/heads/release/v1.2.3
To https://github.com/myorg/myrepo
+ b574c227...4f4725ec HEAD -> release/v1.2.3 (forced update)
Branch 'release/v1.2.3' no longer differs from base branch 'master'
Any idea how to configure this plugin to do what I'm looking for? I simply what to pop open a PR from my current actions branch (a release branch) to master.