Skip to content

Commit 68adf2e

Browse files
committed
init
1 parent 03a8213 commit 68adf2e

File tree

8 files changed

+789
-1
lines changed

8 files changed

+789
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ out
8080

8181
# Nuxt.js build / generate output
8282
.nuxt
83-
dist
8483

8584
# Gatsby files
8685
.cache/

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,73 @@
11
# codeowners-automerge
22
Automerges PRs from code owners that only change owned files.
3+
4+
5+
## Main usecase
6+
You want CODEOWNERS to be able to self-merge PRs to files they are "owners" of.
7+
8+
The code owners could be external users of a public repo, or collaborators added
9+
to a repo that has "Require a pull request before merging" enabled + "Require review from Code Owners".
10+
11+
This bot will check if all files changed in a given PR have the submitter as
12+
their codeowner, and if so the PR will be merged automatically.
13+
14+
Note that if you have branch rules, you will need to give the bot a admin token
15+
in order to be able to bypass rules:
16+
17+
```diff
18+
- GITHUB_TOKEN = ${{ secrets.GITHUB_TOKEN }}
19+
+ GITHUB_TOKEN = ${{ secrets.AUTOMERGE_TOKEN }}
20+
```
21+
22+
>[!NOTE]
23+
>The bot will use as source of truth the CODEOWNERS file at the latest commmit
24+
>of the default branch. In other words a PR that modifies CODEOWNERS will not be
25+
>able to hijack the bot.
26+
27+
## Usage
28+
29+
1. Setup [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) and restrict user's write access to the repo as needed.
30+
2. Add a workflow that uses this Action. If you have other jobs, you might
31+
want to have the automerge job depend on their success.
32+
33+
Example workflow:
34+
35+
```yaml
36+
name: Codeowners Automerge
37+
on:
38+
pull_request_target: { types: [opened, synchronize] }
39+
40+
jobs:
41+
codeowners-automerge:
42+
runs-on: ubuntu-latest
43+
# needs: [other-check1, other-check2]
44+
permissions:
45+
pull-requests: write
46+
contents: write
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
- name: Codeowners Automerge Check
52+
uses: kristoff-it/codeowners-automerge@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
```
56+
57+
Supported options:
58+
59+
```yaml
60+
- name: Codeowners automerge check
61+
uses: kristoff-it/codeowners-automerge@v1
62+
with:
63+
dir: ".github/"
64+
merge_method: 'merge' # 'merge' 'squash' 'rebase'
65+
```
66+
67+
68+
69+
70+
71+
72+
73+

action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Codeowners automerge'
2+
description: 'Automerges PRs from code owners that change only owned code'
3+
author: 'Loris Cro'
4+
5+
branding:
6+
icon: git-merge
7+
color: orange
8+
9+
inputs:
10+
dir:
11+
description: 'Path to the directory containing CODEOWNERS'
12+
default: '.github/'
13+
required: false
14+
15+
merge_method:
16+
description: "The merge strategy to use: 'merge', 'squash' or 'rebase'"
17+
default: 'merge'
18+
required: false
19+
20+
runs:
21+
using: 'node20'
22+
main: 'dist/index.js'

dist/index.js

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 152 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)