Automatically create new PR from specific branch using GitHub actions?

Viewed 1191

I have 3 branches:

  • develop
  • test
  • master

So what I want to do is to setup an automated process to be triggered on test branch getting updated, it will automatically create PR to master.

ie. I create a PR from develop to test then merge, once the merge is completed, I want to setup a GitHub action to automatically create a new PR from test to master.

Is it possible to do this/is there any marketplace action that meet my requirements? Thanks

1 Answers

You can achieve this with create-pull-request. Specifically, this example should help you.

In your case it will look something like this:

name: Create master promotion pull request
on:
  push:
    branches:
      - test
jobs:
  masterPromotion:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: master
      - name: Reset master branch
        run: |
          git fetch origin test:test
          git reset --hard test
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          branch: master-promotion
Related