Skip to content

Merge head into child branch #24

Merge head into child branch

Merge head into child branch #24

Workflow file for this run

name: Merge head into child branch
on:
workflow_dispatch:
inputs:
head:
description: 'Branch to merge from'
required: true
type: choice
options:
- stable
- minor-next
base:
description: 'Branch to merge into'
required: true
type: choice
options:
- minor-next
- major-next
jobs:
merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all branches and their history
- name: Check if head and base are the same
id: check-branches
run: |
if [ "${{ github.event.inputs.head }}" == "${{ github.event.inputs.base }}" ]; then
echo "::error::Head and base branches cannot be the same"
exit 1
fi
- name: Fetch all branches
run: git fetch --all
- name: Checkout base branch
run: git checkout ${{ github.event.inputs.base }}
- name: Set Git config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Attempt to merge head into base
id: merge
run: |
git merge ${{ github.event.inputs.head }}
- name: Check for errors
id: check-errors
run: |
if [ $? -ne 0 ]; then
echo "::error::Merge conflict or error detected"
exit 1
fi
- name: Push changes
if: steps.check-errors.outcome == 'success'
run: |
git push origin ${{ github.event.inputs.base }}