Open piyushchauhan2011 opened 2 years ago
Yes I would like to know this too. For example when there is no changes to be applied it will create an empty commit that does nothing.
I have made a pull request that skips merges for fast-forwards https://github.com/devmasx/merge-branch/pull/28
It would be handy to have a configuration like:
allow_fastforward: true
Is there any update on this issue's original request? In our org we prefer squash merging, and only want to have a single commit on the master/main branch.
If anyone is aware of how to make this possible with devmasx/merge-branch
, or indeed a raw bash/octokit script, please let me know.
@isaachinman
For now I switched to bash script. My use case was to auto sync main
branch to staging
for deployment purposes
name: staging flow
on:
workflow_dispatch: # trigger job manually
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Release to staging
run: |
git config user.email "ci@organization.com"
git config user.name "Organization CI"
git checkout -b staging # staging branch for deployment
git reset --hard main # auto replace staging with main branch for deployment
git push -f --set-upstream origin staging
If staging
branch is protected, it will fail. So generally, best to create a bot github account and give force push rights and set appropriate email and name
@piyushchauhan2011 I believe there are many prebuilt GH actions for that exact purpose. For anyone looking to merge a PR/branch without a merge commit, this is what I ended up with:
name: Auto-Merge Pull Requests
on:
pull_request:
types: [labeled]
jobs:
auto_merge_prs:
name: Auto-Merge PRs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Merge changes into master
run: |
git config --local user.email "actions@github.com"
git config --local user.name "Github Actions"
git switch master
git merge origin/my-branch --no-commit
git push origin master
Quite simple in the end. Will see how it holds up over time.
In terms of branch protection, scope PATs are probably a cleaner solution than bot accounts.
Nice 👍🏼 . I agree with PATs, easier to maintain than bot accounts if they are only used for just this purpose
I want to know if it's possible if we can avoid creating merge commit and do a fast forward with some option. Right now it creates two commits
e.g. https://github.com/piyushchauhan2011/bug-free-palm-tree/commits/staging