github.pullRequests stopped working

I had a working script and it stopped working. I didn’t have any notice or warning of a change in Actions.

I was using:

jobs:
  automerge:
    name: Merge Dependabot pull request
    runs-on: ubuntu-latest
    if: github.base_ref == 'master' && github.actor == 'dependabot[bot]'
    steps:
      - uses: actions/github-script@v2
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            github.pullRequests.merge({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: context.payload.pull_request.number
            })

Now it seems by the documentation github.pullRequests don’t exist anymore and I get the error: Unhandled error: TypeError: Cannot read property 'merge' of undefined.

Any hints here?

@staticdev Please use github.pulls.merge .
In actions/github-script@v2, github object is a pre-authenticated octokit/rest.js client.
According to https://octokit.github.io/rest.js/v18 , pull request merge function is this :

1 Like

That worked as charm! Thanks a lot @yanjingzhu!

1 Like