Skip to content

Commit

Permalink
Allow set of MAX_PR_COUNT from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
agershman committed Sep 16, 2024
1 parent d1203c0 commit 788cba3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 44 deletions.
88 changes: 45 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ After the pull request has been merged successfully, the branch will _not_ be
deleted. To delete branches after they are merged,
see [automatic deletion of branches](https://help.github.com/en/articles/managing-the-automatic-deletion-of-branches).

----
---

**This functionality is now available directly in GitHub as [auto-merge](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/automatically-merging-a-pull-request).** Note that GitHub does not currently support auto-rebasing pull requests. The automerge-action project will still be maintained, but users are encouraged to switch to auto-merge for simple workflows, as it offers a faster and more stable experience.

Expand Down Expand Up @@ -215,49 +215,51 @@ Also, the following general options are supported:

- `BASE_BRANCHES`: If provided, the action will be restricted in terms of base branches. Can be comma-separated list of simple branch names (i.e `main,dev`).

- `MAX_PR_COUNT`: If provided, will control how many GitHub pull requests are considered in a single run. The default is `10`.

You can configure the environment variables in the workflow file like this:

```yaml
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: "automerge,!work in progress"
MERGE_REMOVE_LABELS: "automerge"
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "pull-request-description"
MERGE_FORKS: "false"
MERGE_RETRIES: "6"
MERGE_RETRY_SLEEP: "10000"
MERGE_REQUIRED_APPROVALS: "0"
UPDATE_LABELS: ""
UPDATE_METHOD: "rebase"
PULL_REQUEST: "1234"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: "automerge,!work in progress"
MERGE_REMOVE_LABELS: "automerge"
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "pull-request-description"
MERGE_FORKS: "false"
MERGE_RETRIES: "6"
MERGE_RETRY_SLEEP: "10000"
MERGE_REQUIRED_APPROVALS: "0"
UPDATE_LABELS: ""
UPDATE_METHOD: "rebase"
PULL_REQUEST: "1234"
```

## Supported Events

Automerge can be configured to run for these events:

* `check_run`
* `check_suite`
* `issue_comment`
* `pull_request_review`
* `pull_request_target`
* `pull_request`
* `push`
* `repository_dispatch`
* `schedule`
* `status`
* `workflow_dispatch`
* `workflow_run`
- `check_run`
- `check_suite`
- `issue_comment`
- `pull_request_review`
- `pull_request_target`
- `pull_request`
- `push`
- `repository_dispatch`
- `schedule`
- `status`
- `workflow_dispatch`
- `workflow_run`

For more information on when these occur, see the Github documentation on [events that trigger workflows](https://docs.github.com/en/actions/reference/events-that-trigger-workflows) and [their payloads](https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads).

## Outputs

The action will provide two [outputs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs):

* `mergeResult` - The result from the action run, one of `skipped`, `not_ready`, `author_filtered`, `merge_failed`, `merged`
* `pullRequestNumber` - The pull request number (or `0`, if no pull request was affected)
- `mergeResult` - The result from the action run, one of `skipped`, `not_ready`, `author_filtered`, `merge_failed`, `merged`
- `pullRequestNumber` - The pull request number (or `0`, if no pull request was affected)

Please note:

Expand All @@ -268,16 +270,16 @@ Please note:
Example usage:

```yaml
steps:
- id: automerge
name: automerge
uses: "pascalgn/automerge-action@v0.15.6"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: feedback
if: ${{ steps.automerge.outputs.mergeResult == 'merged' }}
run: |
echo "Pull request ${{ steps.automerge.outputs.pullRequestNumber }} merged!"
steps:
- id: automerge
name: automerge
uses: "pascalgn/automerge-action@v0.15.6"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: feedback
if: ${{ steps.automerge.outputs.mergeResult == 'merged' }}
run: |
echo "Pull request ${{ steps.automerge.outputs.pullRequestNumber }} merged!"
```

## Limitations
Expand All @@ -295,11 +297,11 @@ Example usage:
To run the action with full debug logging, update your workflow file as follows:

```yaml
- name: automerge
uses: pascalgn/automerge-action@...
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
LOG: "TRACE" # or "DEBUG"
- name: automerge
uses: pascalgn/automerge-action@...
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
LOG: "TRACE" # or "DEBUG"
```

If you need to further debug the action, you can run it locally.
Expand Down
2 changes: 1 addition & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const RELEVANT_ACTIONS = [
];

// we'll only update a few PRs at once:
const MAX_PR_COUNT = 10;
const MAX_PR_COUNT = process.env.MAX_PR_COUNT || 10;

async function executeLocally(context, url) {
const { octokit } = context;
Expand Down

0 comments on commit 788cba3

Please sign in to comment.