-
Notifications
You must be signed in to change notification settings - Fork 2
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 0230f30
Showing
365 changed files
with
87,695 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,22 @@ | ||
name: Pull Request | ||
|
||
on: | ||
pull_request: | ||
types: [created] | ||
|
||
jobs: | ||
auto-approve: | ||
name: Label PRs | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v1 | ||
- name: PR Labeler | ||
uses: ./ | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
fix: 'Fix' | ||
feature: 'Feature' | ||
pref: 'Performance Improvement' | ||
preformance: 'Performance Improvement' |
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 @@ | ||
name: 'PR Labels' | ||
description: 'Automatically label PRs based on the branch prefix' | ||
inputs: | ||
token: | ||
description: 'GitHub Token for the user to perform label additions. Use `secrets.GITHUB_TOKEN` for the actions bot' | ||
required: true | ||
runs: | ||
using: 'node12' | ||
main: 'index.js' |
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,64 @@ | ||
const core = require('@actions/core'), | ||
github = require('@actions/github'); | ||
|
||
async function run() { | ||
try { | ||
const token = core.getInput('token'); | ||
const labels = Object.keys(process.env).filter(e => e !== 'INPUT_TOKEN' && e.startsWith('INPUT_')).map(e => e.replace('INPUT_', '').toLowerCase()); | ||
console.log(`Checking for labels: ` + labels.join(', ')); | ||
|
||
const prNumber = getPrNumber(); | ||
if (!prNumber) { | ||
console.log('Could not get pull request number from context, exiting'); | ||
return; | ||
} | ||
|
||
const client = github.getOctokit(token); | ||
|
||
const repo = github.context.payload.repository; | ||
|
||
const data = await client.pulls.get({ | ||
owner: repo.owner.login, | ||
repo: repo.name, | ||
pull_number: prNumber, | ||
}); | ||
|
||
const branch = data.data.head.ref; | ||
|
||
for (let prefix of labels) { | ||
let tmp = prefix; | ||
if (!prefix.endsWith('/')) | ||
prefix += '/'; | ||
|
||
console.log(`If ${branch} startsWith ${prefix}`) | ||
if (branch.startsWith(prefix)) { | ||
const label = process.env['INPUT_' + tmp.toUpperCase()]; | ||
console.log(`Adding ${label} to #${prNumber}`); | ||
await addLabels(client, prNumber, [label]); | ||
} | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
async function addLabels(client, prNumber, labels) { | ||
await client.issues.addLabels({ | ||
owner: github.context.repo.owner, | ||
repo: github.context.repo.repo, | ||
issue_number: prNumber, | ||
labels: labels | ||
}); | ||
} | ||
|
||
function getPrNumber() { | ||
const pullRequest = github.context.payload.pull_request; | ||
if (!pullRequest) { | ||
return undefined; | ||
} | ||
|
||
return pullRequest.number; | ||
} | ||
|
||
run(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.