automerge-action icon indicating copy to clipboard operation
automerge-action copied to clipboard

Fails to merge more than 50% of the time

Open snowe2010 opened this issue 2 years ago • 3 comments

This action fails to merge quite a lot, with a message similar to this:

2022-06-14T23:46:20.005Z INFO  Event name: pull_request
2022-06-14T23:46:20.576Z INFO  Skipping PR update, required label missing: automerge
2022-06-14T23:46:20.576Z INFO  Merging PR #41 Fix pps values for monthly (maybe prepaid)
2022-06-14T23:46:20.577Z INFO  PR is probably ready: mergeable_state: unstable
2022-06-14T23:46:20.953Z INFO  Failed to merge PR: Not Found
2022-06-14T23:46:20.953Z INFO  Retrying after 5000 ms ... (1/6)
2022-06-14T23:46:26.828Z INFO  Failed to merge PR: Not Found
2022-06-14T23:46:26.828Z INFO  Retrying after 5000 ms ... (2/6)
2022-06-14T23:46:32.748Z INFO  Failed to merge PR: Not Found
2022-06-14T23:46:32.748Z INFO  Retrying after 5000 ms ... (3/6)
2022-06-14T23:46:38.645Z INFO  Failed to merge PR: Not Found
2022-06-14T23:46:38.645Z INFO  Retrying after 5000 ms ... (4/6)
2022-06-14T23:46:44.550Z INFO  Failed to merge PR: Not Found
2022-06-14T23:46:44.550Z INFO  Retrying after 5000 ms ... (5/6)
2022-06-14T23:46:50.411Z INFO  Failed to merge PR: Not Found
2022-06-14T23:46:50.412Z INFO  Retrying after 5000 ms ... (6/6)
2022-06-14T23:46:56.277Z INFO  Failed to merge PR: Not Found
2022-06-14T23:46:56.277Z INFO  PR not ready to be merged after 6 tries
2022-06-14T23:46:56.277Z INFO  Action result: { mergeResult: 'merge_failed', pullRequestNumber: 41 }

where it tries over and over to merge, even stating that it has the pull request number, but never merging. We always have to merge it manually. Thing is, this doesn't happen every time. Only most of the time.

snowe2010 avatar Jun 14 '22 23:06 snowe2010

Can you maybe try with debug output as described in the README? Maybe it will show some more info

pascalgn avatar Jun 16 '22 18:06 pascalgn

@pascalgn I'm not sure whether you will agree with me but I think debug should be on by default

nopeless avatar Jul 10 '22 09:07 nopeless

I had the same error all the time and needed to add the following:

    permissions:
      contents: write

ffjdm avatar Aug 21 '22 18:08 ffjdm

I think this is maybe fixed with the suggestion from ffjdm. However, it's a long time since there was some activity in this issue, so I will close it for now. If you have any new information or need any help, feel free to reopen this issue!

pascalgn avatar Oct 07 '22 19:10 pascalgn

@pascalgn sorry, it takes quite a long time to get back to stuff with all the things I'm working on. I'll reopen/comment again when I find time to take a look back at these errors.

snowe2010 avatar Oct 11 '22 15:10 snowe2010

I'm back to looking at this and I've turned on TRACE logging. I'm able to see that it is able to find the PR just fine:

2023-04-21T21:56:38.543Z DEBUG Getting latest PR data...
2023-04-21T21:56:38.804Z TRACE PR: {
  url: 'https://api.github.com/repos/company/repo-testbench/pulls/17',
  html_url: 'https://github.com/company/repo-testbench/pull/17',
  diff_url: 'https://github.com/company/repo-testbench/pull/17.diff',
  patch_url: 'https://github.com/company/repo-testbench/pull/17.patch',
  issue_url: 'https://api.github.com/repos/company/repo-testbench/issues/17',
  number: 17,
  state: 'open',
  locked: false,
  title: 'Try releasing with a fixed github actions',
  user: {
    login: 'snowe2010',
    ...
  },
  created_at: '2023-04-19T02:02:14Z',
  updated_at: '2023-04-21T21:49:03Z',
  closed_at: null,
  merged_at: null,
  merge_commit_sha: '13d55cf1765e810b901b5e9ff2e6d5f88f08c21d',
  ...
}
2023-04-21T21:56:38.897Z INFO  Failed to merge PR: Not Found
2023-04-21T21:56:38.897Z INFO  Retrying after 30000 ms ... (15/60)

That's if I use a PAT. If I use the GITHUB_TOKEN with permission: write-all which sets all permissions to write then instead I get a Resource not found error:

  env:
    AWS_REGION: us-west-2
    AWS_DEFAULT_REGION: us-west-2
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    BRANCH_NAME: create-docker-tags
    GITHUB_TOKEN: ***
    MERGE_LABELS:
    MERGE_METHOD: squash
    MERGE_COMMIT_MESSAGE: pull-request-title-and-description
    MERGE_RETRIES: 60
    MERGE_RETRY_SLEEP: 30000
    MERGE_DELETE_BRANCH: true
    MERGE_ERROR_FAIL: true
    UPDATE_LABELS: autoupdate
    UPDATE_RETRIES: 60
    UPDATE_RETRY_SLEEP: 30000
    LOG: TRACE
2023-04-21T21:06:17.131Z DEBUG Configuration: {
  mergeLabels: { required: [], blocking: [] },
  mergeRemoveLabels: [],
  mergeMethod: 'squash',
  mergeMethodLabels: [],
  mergeMethodLabelRequired: false,
  mergeForks: true,
  mergeCommitMessage: 'pull-request-title-and-description',
  mergeCommitMessageRegex: '',
  mergeFilterAuthor: '',
  mergeRetries: 60,
  mergeRetrySleep: 30000,
  mergeRequiredApprovals: 0,
  mergeDeleteBranch: true,
  mergeDeleteBranchFilter: [],
  mergeErrorFail: true,
  mergeReadyState: [ 'clean', 'has_hooks', 'unknown', 'unstable' ],
  updateLabels: { required: [ 'autoupdate' ], blocking: [] },
  updateMethod: 'merge',
  updateRetries: 60,
  updateRetrySleep: 30000,
  baseBranches: [],
  pullRequest: null
}
2023-04-21T21:06:17.137Z INFO  Event name: pull_request
2023-04-21T21:06:17.137Z TRACE Event data: {
  action: 'labeled',
  number: 17,
  pull_request: {
    _links: {
      comments: {...},
      commits: {...},
      html: {...},
      issue: {...},
      review_comment: {...},
      review_comments: {...},
      self: {...},
      statuses: {...}
    },
    issue_url: 'https://api.github.com/repos/company/repo-testbench/issues/17',
    locked: false,
    mergeable: true,
    mergeable_state: 'unstable',
    merged: false,
    number: 17,
    state: 'open',
    title: 'Try releasing with a fixed github actions',
    url: 'https://api.github.com/repos/company/repo-testbench/pulls/17',
  },
  repository: {
    ...
  },
  sender: {
    ...
  }
}
2023-04-21T21:06:17.139Z DEBUG Getting pull request info for 17 ...
2023-04-21T21:06:17.307Z HttpError: Resource not accessible by integration
    at /home/runner/work/_actions/pascalgn/automerge-action/v0.15.6/dist/index.js:5522:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async fetchPullRequest (/home/runner/work/_actions/pascalgn/automerge-action/v0.15.6/dist/index.js:440:31)
    at async handlePullRequestUpdate (/home/runner/work/_actions/pascalgn/automerge-action/v0.15.6/dist/index.js:128:23)
    at async executeGitHubActionImpl (/home/runner/work/_actions/pascalgn/automerge-action/v0.15.6/dist/index.js:105:12)
    at async executeGitHubAction (/home/runner/work/_actions/pascalgn/automerge-action/v0.15.6/dist/index.js:76:18)
    at async main (/home/runner/work/_actions/pascalgn/automerge-action/v0.15.6/dist/index.js:23069:5)

The logs here don't seem very helpful... No error codes or messages.

snowe2010 avatar Apr 21 '23 22:04 snowe2010