Kev
Kev

Reputation: 306

Github Actions automerge not working as expected

I have a yml file with 5 jobs as below

  1. build - working
  2. unit tests - working
  3. regression tests - working
  4. create pull request - working
  5. merge pull request - not working

The first 3 jobs work on my development branch so my file begins with

name: Spicethedeploy
on:
  push:
    branches: 
    - development
    
jobs:

Job 4 I specify this

source_branch: "development"                      
destination_branch: "master"       

But when job 5 runs it looks for a pull request for development not master and does not complete. The code for this job is:

  automerge:
    needs: pull-request
    runs-on: ubuntu-latest
    steps:
    - name: automerge
      uses: pascalgn/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.ghp_xxxxxxxxxxxxxxxxxxxx }}        

Can someone tell me how to make this job look to the master branch?

I have created a second yml file called automerge.yml, contents below

name: automerge
on:
  pull_request:
    branches: 
    - master
    
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
    - name: automerge
      uses: pascalgn/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.ghp_xxxxxxxxxxxxxxxxxxxxxxxx }}        
        MERGE_LABELS: "automerge"

The pull request has also been removed from the first yml file which now stops after creating the pull request. The new yml file then kicks in and tries to merge but skips with this message

Run pascalgn/[email protected]
2021-04-04T18:36:14.889Z INFO  Event name: pull_request
2021-04-04T18:36:15.102Z INFO  Skipping PR update, required label missing: automerge
2021-04-04T18:36:15.102Z INFO  Skipping PR merge, required label missing: automerge

Upvotes: 0

Views: 1645

Answers (2)

aniket
aniket

Reputation: 36

The documentation on MERGE_LABELS: here says -

When an empty string ("") is given, all pull requests will be merged.

Following that, this worked for me

- id: automerge
    name: automerge
    uses: "pascalgn/[email protected]"
    env:
      GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
      MERGE_LABELS: ""

Upvotes: 2

Kev
Kev

Reputation: 306

Thanks to GuiFalourd for the tips which pointed me in the right direction on this. Following his advice led me to this solution which works well

 merge:
    needs: pull-request
    name: merge
    runs-on: ubuntu-latest
    steps:
    - name: checkout
      uses: actions/checkout@v2
    - name: merge
      uses: mtanzi/action-automerge@v1
      id: merge
      with:
        github_token: ${{ secrets.ghp_xxxxxxxxxxxxxxxxxxxxxxxxx }}
        source: 'development'
        target: 'master'    

Upvotes: 0

Related Questions