-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 91b02d9
Showing
12 changed files
with
5,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# The ID of your GitHub App | ||
APP_ID= | ||
WEBHOOK_SECRET=development | ||
|
||
# Uncomment this to get verbose logging | ||
# LOG_LEVEL=trace # or `info` to show less | ||
|
||
# Subdomain to use for localtunnel server. Defaults to your local username. | ||
# SUBDOMAIN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
npm-debug.log | ||
*.pem | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "7.7.1" | ||
notifications: | ||
disabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ISC License | ||
|
||
Copyright (c) [year], {{ author }} | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# {{ name }} | ||
|
||
> a GitHub App built with [probot](https://github.com/probot/probot) that {{ description }} | ||
## Setup | ||
|
||
``` | ||
# Install dependencies | ||
npm install | ||
# Run the bot | ||
npm start | ||
``` | ||
|
||
See [docs/deploy.md](docs/deploy.md) if you would like to run your own instance of this plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"env": { | ||
"PRIVATE_KEY": { | ||
"description": "the private key you downloaded when creating the GitHub App" | ||
}, | ||
"APP_ID": { | ||
"description": "the ID of your GitHub App" | ||
}, | ||
"WEBHOOK_SECRET": { | ||
"description": "the secret configured for your GitHub App" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Deploying | ||
|
||
If you would like to run your own instance of this plugin, see the [docs for deploying plugins](https://github.com/probot/probot/blob/master/docs/deployment.md). | ||
|
||
This plugin requires these **Permissions & events** for the GitHub App: | ||
|
||
> **TODO**: List permissions required for deployment here. See [probot/stale](https://github.com/probot/stale/blob/master/docs/deploy.md) for an example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const yaml = require('js-yaml'); | ||
const minimatch = require('minimatch'); | ||
|
||
module.exports = robot => { | ||
robot.on('pull_request.opened', autolabel); | ||
robot.on('pull_request.synchronize', autolabel); | ||
|
||
async function autolabel(context) { | ||
const content = await context.github.repos.getContent(context.repo({ | ||
path: '.github/autolabeler.yml' | ||
})); | ||
const config = yaml.load(Buffer.from(content.data.content, 'base64').toString()); | ||
|
||
const files = await context.github.pullRequests.getFiles(context.issue()); | ||
const changedFiles = files.data.map(file => file.filename); | ||
|
||
const labels = new Set(); | ||
|
||
// eslint-disable-next-line guard-for-in | ||
for (const label in config) { | ||
robot.log('looking for changes', label, config[label]); | ||
|
||
const matches = [].concat(config[label]).find(glob => { | ||
robot.log('comparing', glob, changedFiles); | ||
return changedFiles.find(file => { | ||
robot.log('matching', file, glob, minimatch(file, glob)); | ||
return minimatch(file, glob); | ||
}); | ||
}); | ||
|
||
if (matches) { | ||
robot.log('adding label', label); | ||
labels.add(label); | ||
} | ||
} | ||
|
||
const labelsToAdd = Array.from(labels); | ||
|
||
robot.log('Adding labels', labelsToAdd); | ||
if (labelsToAdd.length > 0) { | ||
return context.github.issues.addLabels(context.issue({ | ||
labels: labelsToAdd | ||
})); | ||
} | ||
} | ||
}; |
Oops, something went wrong.