Guide: One-Click Automated Git Conflict Resolution via GitHub Actions
This document provides a zero-setup, "one-click" mobile solution to automatically merge a feature branch into a target branch. It bypasses manual terminal input by leveraging GitHub Actions cloud servers to auto-accept your current branch's changes (-X ours) when conflicts arise.
1. Workflow Configuration
Create a file in your repository named .github/workflows/auto-merge.yml and paste the exact configuration below.
master or develop instead of main, change occurrences of main on lines 21 and 23.
name: One-Click Force Merge
on:
workflow_dispatch:
permissions:
contents: write
jobs:
merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Auto Merge Favoring Current
run: |
git config user.name "GitHub Action"
git config user.email "actions@github.com"
git checkout main
git merge ${{ github.ref_name }} -X ours --no-edit
git push origin main
2. Required GitHub Repository Settings
To prevent Error: 403 (Exit Code 128) permission blocks, GitHub requires explicit write permissions for workflows. Ensure this is configured using either Option A or Option B.
Option A: The YAML Permissions Block
The permissions: block added on line 5 of the configuration explicitly grants the token write permissions for the lifecycle of that specific workflow run.
Option B: The Global Repository Toggle
If your organization policies override the YAML configuration block:
- Open your repository in a web browser.
- Tap the Settings tab at the top.
- On the left sidebar, expand Actions and select General.
- Scroll down to the Workflow permissions heading.
- Select the radio button for Read and write permissions.
- Click Save.
3. Execution Steps (Mobile Web Browser)
Once configured, you can trigger this process directly from your smartphone's web browser without downloading any apps:
- Navigate to your GitHub repository homepage on your phone.
- Tap the Actions tab located in the top navigation bar.
- Select One-Click Force Merge from the left-hand workflow list.
- Tap the Run workflow dropdown button.
- Select the source branch containing your current changes.
- Click the green Run workflow confirmation button.
The GitHub Actions runner will spin up a cloud container, checkout your target branch, automatically accept your feature branch's changes for conflicting lines, and push the clean state back to your repository.
Comments
Post a Comment