Comments (4)
The action is nothing surprising, but actually looking at it now perhaps I should be using git pull
rather than git merge
name: Auto-prepare a PR from update to main
on:
push:
branches:
- update
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Merge update branch into main
run: |
git fetch origin update
git merge origin/update
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
branch: integrate/update-to-main
title: "Merge update into main"
body: "This is an automated pull request to update the main branch with the latest changes from update."
delete-branch: true
from create-pull-request.
Hi @dsyme
Please take a look at this example. I think this is what you are trying to do.
https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#keep-a-branch-up-to-date-with-another
I don't think using merge
is going to work.
from create-pull-request.
Thanks! My scenario is a little different - we have two branches production
and main
but allow changes to flow into both (e.g. hotfixes into production
and normal dev work into main
). I'm using this action to automate the PRs for the integrations between the two.
The problem is that merge commits always appear - and this really stems from the fact that the GitHub UI doesn't support PRs that are fast-forward merges, so the act of merging a PR always leaves a merge commit, squash or rebase of some kind in the commit history. This means that you end up with an endless infinite ping pong of empty merge commits between the two branches.
I found a workaround which is like this. But I do wonder if this could be the default behaviour.
Thank you for the GH action btw, it's very useful!
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: production
fetch-depth: 0
- name: Promote main to production
run: |
git config --global pull.ff only
git config --global user.email "..."
git config --global user.name "..."
git fetch origin
# Check if there are any actual code differences between the two branches. If so, merge
# the main branch into production. If not, do nothing, which will not result in creation of a PR.
# This prevents PRs being created when there are no actual code changes only merge commits
if git diff --quiet origin/production...origin/main; then
echo "production branch already includes everything from main branch"
else
git merge origin/main
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
branch: integrate/main-to-production
title: "[Release] Promote main to production"
delete-branch: true
from create-pull-request.
Maybe to avoid the merge commits you could try this in your workflow:
- checkout production
- fetch main (origin)
- create a new local branch on the HEAD of production called
temp-merge
, for example - merge
origin/main
intotemp-merge
- checkout production again (this part is like the example I linked, but we don't need to fetch because
temp-merge
is already available locally) - do
git reset --hard temp-merge
- run create-pull-request
Apologies if I misunderstood and this doesn't work. 😄
from create-pull-request.
Related Issues (20)
- bit
- I'm confused what the `base` option is supposed to do HOT 1
- Don't require a deep fetch for forks HOT 11
- Token generated from GitHub App not working with push-to-fork HOT 4
- Default to "Squash and Merge" HOT 1
- I get error "protected branch hook declined" when I try to create a draft pull request into protected branch HOT 1
- Force update the branch of existing pull request HOT 1
- Error creating new PR HOT 2
- `title-path` and `commit-message-path` inputs HOT 1
- `base` also does a checkout to that branch HOT 1
- Update multiple repositories HOT 2
- ignore untracked HOT 2
- NO PR created and branch changes to new branch and updates from main HOT 5
- Required checks are not being triggered after the PR creation HOT 1
- Error: Input 'token' not supplied. Unable to continue. HOT 1
- Changes from test folder doesn't added to the PR HOT 7
- Node version - Warning HOT 1
- Permission denied (publickey) HOT 1
- Merge conflict error for different files with different names
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-pull-request.