Skip to content

Specify fetch-depth #21

Specify fetch-depth

Specify fetch-depth #21

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:

Check failure on line 28 in .github/workflows/auto-merge.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/auto-merge.yml

Invalid workflow file

You have an error in your yaml syntax on line 28
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 --no-commit ${{ github.event.inputs.head }} || echo "Merge conflict detected" > conflict.txt
- name: Check for merge conflicts
id: check-conflict
run: |
if [ -f conflict.txt ]; then
echo "::error::Merge conflict detected"
exit 1
fi
- name: Commit the merge
if: steps.check-conflict.outcome == 'success'
run: |
git commit -m "Merge '${{ github.event.inputs.head }}' into ${{ github.event.inputs.base }}"
git push origin ${{ github.event.inputs.base }}