Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Auto-update is a minimalist [JavaScript GitHub action](https://help.github.com/en/articles/about-actions#javascript-actions) to keep pull requests with [auto-merge](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/automatically-merging-a-pull-request) enabled [up to date with their base branch](https://developer.github.com/changes/2019-05-29-update-branch-api/).
Auto-update is a minimalist [JavaScript GitHub action](https://help.github.com/en/articles/about-actions#javascript-actions) to keep pull requests with [auto-merge](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/automatically-merging-a-pull-request) enabled [up to date with their base branch](https://developer.github.com/changes/2019-05-29-update-branch-api/). Setting the `ignore_auto_merge` input to `true` will cause all PRs to be updated.

It is the missing piece to really automatically merge pull requests when [strict status checks](https://help.github.com/en/articles/types-of-required-status-checks) are set up to protect against [semantic conflicts](https://bors.tech/essay/2017/02/02/pitch/).

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Auto-update
author: Thibault Derousseaux <tibdex@gmail.com>
description: Automatically keep pull requests with auto-merged enabled up to date with their base branch.
inputs:
ignore_auto_merge:
description: When this is false only PRs with auto-merge enabled will be updated. Setting to true will cause all PRs to be updated.
default: false
github_token:
description: Token for the GitHub API.
default: ${{ github.token }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auto-update",
"version": "2.2.1",
"version": "2.3.0",
"license": "MIT",
"type": "module",
"files": [
Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const handleUnupdatablePullRequest = async (

const handlePullRequest = async (
pullRequest: PullRequest,
ignore_auto_merge: string,
{
eventPayload,
octokit,
Expand All @@ -89,7 +90,7 @@ const handlePullRequest = async (
octokit: InstanceType<typeof GitHub>;
}>,
): Promise<void> => {
if (!pullRequest.auto_merge) {
if (ignore_auto_merge !== "true" && !pullRequest.auto_merge) {
info(
`Pull request #${pullRequest.number} does not have auto-merge enabled`,
);
Expand Down Expand Up @@ -123,6 +124,7 @@ const handlePullRequest = async (

const run = async () => {
try {
const ignore_auto_merge = getInput("ignore_auto_merge", { required: true });
const token = getInput("github_token", { required: true });
const octokit = getOctokit(token);

Expand Down Expand Up @@ -156,7 +158,10 @@ const run = async () => {
for (const pullRequest of pullRequests) {
// PRs are handled sequentially to avoid breaking GitHub's log grouping feature.
// eslint-disable-next-line no-await-in-loop
await handlePullRequest(pullRequest, { eventPayload, octokit });
await handlePullRequest(pullRequest, ignore_auto_merge, {
eventPayload,
octokit,
});
}
} catch (error: unknown) {
setFailed(ensureError(error));
Expand Down