-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - what mergeable_state: blocked means? #122
Comments
@pascalgn I have a similar issue. I have a setup where the PR is auto-approved and all of the required steps have successfully passed, and the last action is the auto-merge. However the auto-merge action keep saying "Current PR status: mergeable_state: blocked" and the PR never gets merged... |
Same issue 😞 |
Same issue here, auto-approve PR and then merge doesn't happen, just the same |
I'm really sorry, but this action can only use the info that the GitHub API is giving. The only way I see is to capture screenshots of the PR, together with outputs of the PR API at the same time and then raise the issue at https://github.community/ but from my experience this will not lead to a (fast) resolution 😞 |
This is technically not true, of course. The experience with the GH API has been quite frustrating, so at this point I would also be relatively open for a PR which replaces the call of the GH API with some undocumented API or even crawling the HTML view of GitHub and checking if the "Merge" button is green... But this would have other issues, of course, possibly breaking the action completely when GitHub changes too much |
I'm having the same issue and it doesn't look like GH issue to me (or maybe i'm missing something) - name: 'Auto merge'
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_LABELS: ''
MERGE_METHOD: squash
MERGE_RETRIES: "12"
MERGE_RETRY_SLEEP: "10000"
LOG: "TRACE" During the run action debug prints the
And so on till the last retry:
During the same time i polled the GH pulls API (ref: https://docs.github.com/en/rest/reference/pulls#get-a-pull-request) {
"author_association": "CONTRIBUTOR",
"auto_merge": null,
"active_lock_reason": null,
"merged": false,
"mergeable": true,
"rebaseable": true,
"mergeable_state": "unstable",
"merged_by": null,
"comments": 0,
"review_comments": 0,
"maintainer_can_modify": false,
"commits": 1,
"additions": 1364,
"deletions": 3570,
"changed_files": 4
} So somehow we are getting cached response from github? or there is a bug in the action itself? |
I don't think it's a bug in the action, we are simply calling the API, using octokit (the official GH client) https://github.com/pascalgn/automerge-action/blob/main/lib/merge.js#L270-L281 async function getPullRequest(octokit, pullRequest) {
logger.debug("Getting latest PR data...");
const { data: pr } = await octokit.pulls.get({
owner: pullRequest.base.repo.owner.login,
repo: pullRequest.base.repo.name,
pull_number: pullRequest.number
});
logger.trace("PR:", pr);
return pr;
} However, your idea sounds good, so I searched for "cache" and found this issue octokit/octokit.js#890 so it looks like at least some replies may be cached. From that issue, I think it could work if you changed the above function to async function getPullRequest(octokit, pullRequest) {
logger.debug("Getting latest PR data...");
const { data: pr } = await octokit.pulls.get({
owner: pullRequest.base.repo.owner.login,
repo: pullRequest.base.repo.name,
pull_number: pullRequest.number,
headers: {
"If-None-Match": ""
}
});
logger.trace("PR:", pr);
return pr;
} You can create a PR for it if you like, or I can also try it |
Thank you! i'll test from fork and will open PR if it works!😊 |
Hi @pascalgn, thanks for maintaining this action, we've been using it in production over at Expensify for about a year now, and for the most part it works great! However, we've also been experiencing this particular issue, and I have two suggestions. First, I noticed that when we reach https://github.com/pascalgn/automerge-action/blob/main/lib/merge.js#L245, the action fails silently, such that a later step in the workflow with Second, I'd like to posit that maybe this action doesn't need to use the (mostly) undocumented
For what it's worth, I wrote a small custom action that polls the GH API to determine the mergeability of pull request, and have seen some workflow runs where my action resolves the mergeability of a pull request to Here's an example workflow run that demonstrates what I'm talking about: https://github.com/Expensify/App/runs/4488449197?check_suite_focus=true And in case it's helpful, here's a simplified version of custom action that I use to check the mergeability of a pull request (translated to use const core = require('@actions/core');
const github = require('@actions/github');
const MAX_RETRIES = 30;
const THROTTLE_DURATION = 5000;
const run = async function () {
const token = core.getInput('GITHUB_TOKEN', {required: true});
const octokit = github.getOctokit(token);
const gitHubOwner = core.getInput('GITHUB_OWNER', {required: true});
const gitHubRepo = core.getInput('GITHUB_REPO', {required: true});
const pullRequestNumber = Number(core.getInput('PULL_REQUEST_NUMBER', {required: true}));
let retryCount = 0;
let isMergeable = false;
let mergeabilityResolved = false;
console.log(`Checking the mergeability of PR #${pullRequestNumber}`);
while (!mergeabilityResolved && retryCount < MAX_RETRIES) {
try {
const mergeable = (
await octokit.pulls.get({
owner: gitHubOwner,
repo: gitHubRepo,
pull_number: pullRequestNumber,
})
).data.mergeable;
if (mergeable === null) {
console.log('Pull request mergeability is not yet resolved...');
retryCount++;
// Wait 5 seconds before trying again
await new Promise(resolve => setTimeout(resolve, THROTTLE_DURATION));
} else {
mergeabilityResolved = true;
isMergeable = mergeable;
}
} catch (apiError) {
mergeabilityResolved = true;
console.error(`An error occurred fetching the PR from Github: ${JSON.stringify(apiError)}`);
core.setFailed(apiError);
return;
}
}
if (retryCount >= MAX_RETRIES) {
console.error('Maximum retries reached, mergeability is undetermined);
core.setFailed(new Error(`Mergeability could not be determined after ${retryCount} retries 😞`));
return;
}
console.log(`Pull request #${pullRequestNumber} is ${isMergeable ? '' : 'not '}mergeable`);
core.setOutput('IS_MERGEABLE', isMergeable);
};
if (require.main === module) {
run();
}
module.exports = run; Let me know your thoughts! If you agree with my suggestions, I can submit a pull request to implement these changes. |
For what it's worth, I think we discovered why this action was failing for us and It still would be preferable if this situation resulted in a failure instead of failing silently, but this is no longer a critical issue for us. |
I submitted a pull request to (loudly) fail the action if the pull request cannot be merged. |
Would it make sense to have an option so that the action checks |
@D4nte Yes, why not! Feel free to create a PR for it! 👍 |
Hi @pascalgn I have got the same issue about merge pull request, this is my step:
this is just for my develop branch where we have protection rules, but the pr was approved, but i don't know why is blocked
There is a solution to merge pull request in a protect branch? |
@roryabraham Regarding this comment #122 (comment), I thought about it some more and I think it could make sense to switch to the mergeable field, so if you still want to provide a PR for it, feel free! |
It'd be great to get a fix for this soon please. The idea of this action is great, but it doesn't work as other comments mentioned. Would love to get this working asap, so I don't need to worry about dependabot prs any more. |
… no commit (#92) issue [Configurar automerge dos PRs sem utilizar kodiak](monde-sistemas/melhorias#349) No commit, estava mostrando apenas o título e os detalhes do PR. Não tinha o link do PR. Estou adicionando essa configuração para mostrar o link do PR no commit. Também estou alterando a forma de fazer o merge, removendo o pascalgn/automerge-action porque ele estava [falhando em alguns PRs](https://github.com/monde-sistemas/m2/actions/runs/12121505151/job/33793229889). Encontrei pascalgn/automerge-action#122 sobre o problema.
I am testing that from a forked repo I cannot auto-merge a PR, the response I get is:
2020-11-10T19:46:56.465Z INFO Event name: pull_request
2020-11-10T19:46:56.780Z INFO Updating PR #1311 Bad PR
2020-11-10T19:46:56.781Z INFO No update done due to PR mergeable_state blocked
2020-11-10T19:46:56.781Z INFO Merging PR #1311 Bad PR
2020-11-10T19:46:56.781Z INFO Current PR status: mergeable_state: blocked
2020-11-10T19:46:56.781Z INFO Retrying after 5000 ms ... (1/6)
2020-11-10T19:47:02.115Z INFO Current PR status: mergeable_state: blocked
2020-11-10T19:47:02.115Z INFO Retrying after 5000 ms ... (2/6)
2020-11-10T19:47:07.482Z INFO Current PR status: mergeable_state: blocked
Not sure if I get blocked because the GITHUB_TOKEN is read only on forks or if is something else, just want to make sure that PRs coming from forks cannot get merged.
Any assistance will be appreciated.
The text was updated successfully, but these errors were encountered: