Skip to content
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

Document cml pr --auto-merge #206

Merged
merged 5 commits into from
Mar 18, 2022
Merged
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
35 changes: 15 additions & 20 deletions content/docs/ref/pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ preventing an infinite chain of runs.

Any [generic option](/doc/ref) in addition to:

- `--auto-merge`: Mark the PR/MR for automatic merging after tests pass
(unsupported by Bitbucket).
- `--md`: Produce output in markdown format (`[CML Pull/Merge Request](url)`
instead of `url`).
- `--remote=<name or URL>`: Git remote name or URL [default: `origin`].
Expand All @@ -29,30 +31,23 @@ Any [generic option](/doc/ref) in addition to:
### Commit all files in current working directory

```bash
cml pr "."
cml pr .
```

### Automatically merge GitHub pull requests

```yaml
on: pull_request
jobs:
cml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: iterative/setup-cml@v1
- name: Generate data
run: echo "Hello World" > output.txt
0x2b3bfa0 marked this conversation as resolved.
Show resolved Hide resolved
- name: Create and merge PR
run: |
cml ci
gh pr merge --rebase $(cml pr "output.txt")
0x2b3bfa0 marked this conversation as resolved.
Show resolved Hide resolved
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
### Automatically merge pull requests

```bash
date > output.txt
cml pr --auto-merge output.txt
```

### Command internals
The `--auto-merge` option enables
[auto–merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request)
(GitHub) or
[merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
(GitLab) to merge the pull/merge request as soon as checks succeed.

## Command internals

```bash
cml pr "**/*.py" "**/*.json"
Expand Down