Perform Github action to automatically merge when I create a pull request

Viewed 38

I'm setting up Github actions for a few of my projects. The flow I'd like to achieve is:

  1. A developer opens a new pull request
  2. The branch is automatically merged with the main branch

My question is, is it possible to achieve this kind of workflow? If not, what are the other possible alternatives?

1 Answers

You could use the GitHub Action "Merge branch", for instance for any feature/xxx branch pushed (you can change the naming convention as you want).

name: Merge any release branch to uat
on:
  push:
    branches:
      - 'feature/*'
jobs:
  merge-branch:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Merge feature/xxx -> main
        uses: devmasx/merge-branch@master
        with:
          type: now
          target_branch: main
          github_token: ${{ github.token }}

Related