Skip to content

Commit a4defb9

Browse files
feat: Build for release
0 parents  commit a4defb9

File tree

494 files changed

+87360
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

494 files changed

+87360
-0
lines changed

LICENSE

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

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Assign Author
2+
3+
[![Build Status](https://github.com/technote-space/assign-author/workflows/Build/badge.svg)](https://github.com/technote-space/assign-author/actions)
4+
[![Coverage Status](https://coveralls.io/repos/github/technote-space/assign-author/badge.svg?branch=master)](https://coveralls.io/github/technote-space/assign-author?branch=master)
5+
[![CodeFactor](https://www.codefactor.io/repository/github/technote-space/assign-author/badge)](https://www.codefactor.io/repository/github/technote-space/assign-author)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/technote-space/assign-author/blob/master/LICENSE)
7+
8+
GitHub actions to assign author to issue or PR.
9+
10+
## Screenshot
11+
12+
## Installation
13+
1. Setup workflow
14+
e.g. `.github/workflows/pull_request.yml`
15+
```yaml
16+
on: pull_request
17+
name: Pull Request
18+
jobs:
19+
assignAuthor:
20+
name: Assign Author to PR
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Assign Author to PR
24+
if: github.event.action == 'opened'
25+
uses: technote-space/assign-author@v1
26+
with:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
```
29+
e.g. `.github/workflows/issues.yml`
30+
```yaml
31+
on: issues
32+
name: Issues
33+
jobs:
34+
assignAuthor:
35+
name: Assign Author to issue
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Assign Author to issue
39+
if: github.event.action == 'opened'
40+
uses: technote-space/assign-author@v1
41+
with:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
```
44+
45+
## Action event details
46+
### Target events
47+
- pull_request: opened
48+
- issues: opened
49+
50+
## Author
51+
[GitHub (Technote)](https://github.com/technote-space)
52+
[Blog](https://technote.space)

action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Assign Author
2+
description: GitHub actions to assign author to issue or PR.
3+
author: technote-space
4+
inputs:
5+
GITHUB_TOKEN:
6+
description: Secret GitHub API token to use for making API requests.
7+
required: true
8+
branding:
9+
icon: 'user-plus'
10+
color: 'orange'
11+
runs:
12+
using: node12
13+
main: lib/main.js

build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"tagName":"v0.0.1","branch":"gh-actions","tags":["v0.0.1","v0","v0.0"],"updated_at":"2019-08-29T05:53:28.708Z"}

lib/constant.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.TARGET_EVENTS = {
4+
'issues': 'opened',
5+
'pull_request': 'opened',
6+
};

lib/main.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
var __importDefault = (this && this.__importDefault) || function (mod) {
12+
return (mod && mod.__esModule) ? mod : { "default": mod };
13+
};
14+
Object.defineProperty(exports, "__esModule", { value: true });
15+
const path_1 = __importDefault(require("path"));
16+
const core_1 = require("@actions/core");
17+
const github_1 = require("@actions/github");
18+
const signale_1 = __importDefault(require("signale"));
19+
const misc_1 = require("./utils/misc");
20+
const context_1 = require("./utils/context");
21+
const github_2 = require("./utils/github");
22+
function run() {
23+
return __awaiter(this, void 0, void 0, function* () {
24+
try {
25+
const version = misc_1.getBuildVersion(path_1.default.resolve(__dirname, '..', 'build.json'));
26+
if ('string' === typeof version) {
27+
signale_1.default.info('Version: %s', version);
28+
}
29+
signale_1.default.info('Event: %s', github_1.context.eventName);
30+
signale_1.default.info('Action: %s', github_1.context.payload.action);
31+
if (!misc_1.isTargetEvent(github_1.context)) {
32+
signale_1.default.info('This is not target event.');
33+
return;
34+
}
35+
yield github_2.addAssignees(context_1.getAssignees(github_1.context), new github_1.GitHub(core_1.getInput('GITHUB_TOKEN', { required: true })), github_1.context);
36+
}
37+
catch (error) {
38+
core_1.setFailed(error.message);
39+
}
40+
});
41+
}
42+
run();

lib/utils/context.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.getAssignees = (context) => {
4+
const sender = getSender(context);
5+
if (false === sender)
6+
return false;
7+
const assignees = getCurrentAssignees(context);
8+
if (false === assignees)
9+
return false;
10+
if (assignees.includes(sender))
11+
return [];
12+
return [sender];
13+
};
14+
const getSender = (context) => context.payload.sender && context.payload.sender.type === 'User' ? context.payload.sender.login : false;
15+
const getCurrentAssignees = (context) => context.payload.issue && 'assignees' in context.payload.issue ? context.payload.issue.assignees.map(assignee => assignee.login) : false;

lib/utils/github.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
var __importDefault = (this && this.__importDefault) || function (mod) {
12+
return (mod && mod.__esModule) ? mod : { "default": mod };
13+
};
14+
Object.defineProperty(exports, "__esModule", { value: true });
15+
const signale_1 = __importDefault(require("signale"));
16+
exports.addAssignees = (assignees, octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
17+
if (false === assignees) {
18+
signale_1.default.warn('Invalid target.');
19+
signale_1.default.info(context.issue);
20+
return;
21+
}
22+
signale_1.default.info('Adding assignees');
23+
signale_1.default.info(assignees);
24+
if (!assignees.length)
25+
return;
26+
yield octokit.issues.addAssignees({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
issue_number: context.issue.number,
30+
assignees: assignees,
31+
});
32+
});

lib/utils/misc.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const fs_1 = __importDefault(require("fs"));
7+
const constant_1 = require("../constant");
8+
exports.isTargetEvent = (context) => 'string' === typeof context.payload.action && context.eventName in constant_1.TARGET_EVENTS && constant_1.TARGET_EVENTS[context.eventName] === context.payload.action;
9+
exports.getBuildVersion = (filepath) => {
10+
if (!fs_1.default.existsSync(filepath)) {
11+
return false;
12+
}
13+
const json = JSON.parse(fs_1.default.readFileSync(filepath, 'utf8'));
14+
if (json && 'tagName' in json) {
15+
return json['tagName'];
16+
}
17+
return false;
18+
};

node_modules/.bin/semver

Lines changed: 1 addition & 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)