Skip to content

Commit 1c9a947

Browse files
Merge pull request #6 from UcheSylvester/docs
Docs
2 parents d9da8ae + dbfc7da commit 1c9a947

File tree

7 files changed

+137
-4
lines changed

7 files changed

+137
-4
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defaults:
99
shell: 'bash'
1010

1111
jobs:
12-
Smartrr:
12+
request-reviews:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout repository

LICENSE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Uchenna Sylvester Okoro
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Pr Smartrr
2+
3+
<div style="display:flex; gap:20px; flex-wrap:wrap">
4+
<a href="https://github.com/marketplace/actions/pr-smartrr" style="text-decoration:none">
5+
<img src="https://img.shields.io/github/release/UcheSylvester/pr-smartrr.svg" />
6+
</a>
7+
8+
<a href="https://github.com/marketplace/actions/pr-smartrr" style="text-decoration:none">
9+
<img src="https://img.shields.io/badge/marketplace-pr--smartrr-green?logo=github" />
10+
</a>
11+
12+
<a href="https://github.com/marketplace/actions/pr-smartrr" style="text-decoration:none">
13+
<img src="https://img.shields.io/github/languages/top/UcheSylvester/pr-smartrr.svg" />
14+
</a>
15+
</div>
16+
17+
---
18+
19+
This GitHub Action automatically requests reviews on pull requests based on changed files.
20+
21+
It does this by checking the teammates with commits on those changed files and adding them as reviewers to pull requests. This means you do not need to manually provide a list of reviewers to this action.
22+
23+
## Inputs
24+
25+
#### `github-token`
26+
27+
**Required** The GitHub token to use for authentication. Typically, this should be set to `${{ secrets.GITHUB_TOKEN }}`.
28+
29+
#### `max-reviewers`
30+
31+
**Optional** The maximum number of reviewers to be added to the pull request. _Defaults to 2_.
32+
33+
## Usage
34+
35+
1. **Create a Workflow YAML File**: In your repository, create or edit a workflow YAML file (e.g., `.github/workflows/main.yml`).
36+
37+
2. **Define the Workflow**:
38+
39+
```yaml
40+
name: main
41+
42+
on:
43+
pull_request:
44+
types: [opened]
45+
46+
defaults:
47+
run:
48+
shell: 'bash'
49+
50+
jobs:
51+
request-reviews:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v3
56+
with:
57+
# Note: this is required for the action to work
58+
fetch-depth: 0
59+
60+
- name: Auto PR review requests
61+
uses: UcheSylvester/pr-smartrr@v0.1.0
62+
with:
63+
github-token: ${{ secrets.GITHUB_TOKEN }}
64+
max-reviewers: 2
65+
```
66+
67+
## Run Locally
68+
69+
To run this action locally, you need to have [Node.js](https://nodejs.org/en/) installed on your machine.
70+
71+
1. Clone this repository:
72+
73+
```bash
74+
git clone
75+
```
76+
77+
2. Install dependencies:
78+
79+
```bash
80+
yarn
81+
```
82+
83+
3. Build the typescript:
84+
85+
```bash
86+
yarn build
87+
```
88+
89+
4. Run the tests:
90+
91+
```bash
92+
yarn test
93+
```
94+
95+
5. Run the local action with [nektos/act](https://github.com/nektos/act):
96+
97+
```bash
98+
act -j pr-labelr -s GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
99+
```
100+
101+
## Contributing
102+
103+
We welcome contributions from the community to make **Pr Smartrr** even better. Whether it's bug fixes, new features, or improvements to documentation, your input is valuable. To contribute, follow these steps:
104+
105+
1. Create an issue describing the feature/bug you want to work on.
106+
2. Fork the repository on GitHub.
107+
3. Create a new branch for your changes.
108+
4. Make your changes and commit them with descriptive messages.
109+
5. Submit a pull request to the main repository.
110+
111+
## License
112+
113+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
114+
115+
---
116+
117+
## Get In Touch
118+
119+
[Email](mailto:okorocode@gmail.com) | [Follow on Twitter](https://twitter.com/ucylvester) | [Connect on LinkedIn](https://www.linkedin.com/in/uchenna-okoro/) | [Report an Issue](https://github.com/UcheSylvester/pr-smartrr/issues)

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Smartrr'
1+
name: 'Pr Smartrr'
22
description: 'Automatically request reviews on pull requests based on changed files.'
33
author: 'Uchenna Sylvester Okoro'
44

dist/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const getChangedFiles = async (base, head) => {
4343
return reject(new Error(error.message));
4444
if (stderr)
4545
return reject(new Error(stderr));
46+
console.log('changed files', stdout);
4647
resolve(stdout);
4748
});
4849
});

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"name": "smartrr",
3-
"version": "1.0.0",
2+
"name": "pr-smartrr",
3+
"version": "0.1.0",
44
"main": "index.js",
55
"license": "MIT",
6+
"author": {
7+
"name": "Uchenna Sylvester Okoro"
8+
},
69
"scripts": {
710
"clean": "rimraf dist && rimraf lib",
811
"build": "pnpm clean && tsc && ncc build lib/index.js",

src/helpers/get-changed-files.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const getChangedFiles = async (base: string, head: string) => {
55
exec(`git diff --name-only ${base} ${head}`, (error, stdout, stderr) => {
66
if (error) return reject(new Error(error.message));
77
if (stderr) return reject(new Error(stderr));
8+
console.log('changed files', stdout);
89
resolve(stdout);
910
});
1011
});

0 commit comments

Comments
 (0)