Skip to content

Commit 83a86bf

Browse files
feat: build for release
0 parents  commit 83a86bf

File tree

590 files changed

+190054
-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.

590 files changed

+190054
-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.ja.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Assign Author
2+
3+
[![CI Status](https://github.com/technote-space/assign-author/workflows/CI/badge.svg)](https://github.com/technote-space/assign-author/actions)
4+
[![codecov](https://codecov.io/gh/technote-space/assign-author/branch/master/graph/badge.svg)](https://codecov.io/gh/technote-space/assign-author)
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+
*Read this in other languages: [English](README.md), [日本語](README.ja.md).*
9+
10+
Issue や Pull Request に Author をアサインする GitHub Actions です。
11+
12+
## Table of Contents
13+
14+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
15+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
16+
<details>
17+
<summary>Details</summary>
18+
19+
- [スクリーンショット](#%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88)
20+
- [インストール](#%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB)
21+
- [Action イベント詳細](#action-%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E8%A9%B3%E7%B4%B0)
22+
- [対象イベント](#%E5%AF%BE%E8%B1%A1%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88)
23+
- [このアクションを使用しているリポジトリの例](#%E3%81%93%E3%81%AE%E3%82%A2%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%83%AA%E3%83%9D%E3%82%B8%E3%83%88%E3%83%AA%E3%81%AE%E4%BE%8B)
24+
- [Author](#author)
25+
26+
</details>
27+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
28+
29+
## スクリーンショット
30+
![GitHub Action](https://raw.githubusercontent.com/technote-space/assign-author/images/screenshot.gif)
31+
32+
## インストール
33+
1. workflow を設定
34+
e.g. `.github/workflows/pull_request.yml`
35+
```yaml
36+
on:
37+
pull_request:
38+
types: [opened]
39+
name: Pull Request
40+
jobs:
41+
assignAuthor:
42+
name: Assign author to PR
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Assign author to PR
46+
uses: technote-space/assign-author@v1
47+
```
48+
e.g. `.github/workflows/issues.yml`
49+
```yaml
50+
on:
51+
issues:
52+
types: [opened]
53+
name: Issues
54+
jobs:
55+
assignAuthor:
56+
name: Assign author to issue
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Assign author to issue
60+
uses: technote-space/assign-author@v1
61+
```
62+
63+
## Action イベント詳細
64+
### 対象イベント
65+
| eventName | action |
66+
|:---:|:---:|
67+
|pull_request|opened|
68+
|pull_request|rerequested|
69+
|issues|opened|
70+
|issues|rerequested|
71+
72+
## このアクションを使用しているリポジトリの例
73+
- [Release GitHub Actions](https://github.com/technote-space/release-github-actions)
74+
- [issue-opened.yml](https://github.com/technote-space/release-github-actions/blob/master/.github/workflows/issue-opened.yml)
75+
- [pr-opened.yml](https://github.com/technote-space/release-github-actions/blob/master/.github/workflows/pr-opened.yml)
76+
- [Auto card labeler](https://github.com/technote-space/auto-card-labeler)
77+
- [issue-opened.yml](https://github.com/technote-space/auto-card-labeler/blob/master/.github/workflows/issue-opened.yml)
78+
- [pr-opened.yml](https://github.com/technote-space/auto-card-labeler/blob/master/.github/workflows/pr-opened.yml)
79+
- [Assign Author](https://github.com/technote-space/assign-author)
80+
- [issue-opened.yml](https://github.com/technote-space/assign-author/blob/master/.github/workflows/issue-opened.yml)
81+
- [pr-opened.yml](https://github.com/technote-space/assign-author/blob/master/.github/workflows/pr-opened.yml)
82+
- [TOC Generator](https://github.com/technote-space/toc-generator)
83+
- [issue-opened.yml](https://github.com/technote-space/toc-generator/blob/master/.github/workflows/issue-opened.yml)
84+
- [pr-opened.yml](https://github.com/technote-space/toc-generator/blob/master/.github/workflows/pr-opened.yml)
85+
- [Package Version Check Action](https://github.com/technote-space/package-version-check-action)
86+
- [issue-opened.yml](https://github.com/technote-space/package-version-check-action/blob/master/.github/workflows/issue-opened.yml)
87+
- [pr-opened.yml](https://github.com/technote-space/package-version-check-action/blob/master/.github/workflows/pr-opened.yml)
88+
- [Get Diff Action](https://github.com/technote-space/get-diff-action)
89+
- [issue-opened.yml](https://github.com/technote-space/get-diff-action/blob/master/.github/workflows/issue-opened.yml)
90+
- [pr-opened.yml](https://github.com/technote-space/get-diff-action/blob/master/.github/workflows/pr-opened.yml)
91+
- [Create Project Card Action](https://github.com/technote-space/create-project-card-action)
92+
- [issue-opened.yml](https://github.com/technote-space/create-project-card-action/blob/master/.github/workflows/issue-opened.yml)
93+
- [pr-opened.yml](https://github.com/technote-space/create-project-card-action/blob/master/.github/workflows/pr-opened.yml)
94+
- [Get git comment action](https://github.com/technote-space/get-git-comment-action)
95+
- [issue-opened.yml](https://github.com/technote-space/get-git-comment-action/blob/master/.github/workflows/issue-opened.yml)
96+
- [pr-opened.yml](https://github.com/technote-space/get-git-comment-action/blob/master/.github/workflows/pr-opened.yml)
97+
98+
## Author
99+
[GitHub (Technote)](https://github.com/technote-space)
100+
[Blog](https://technote.space)

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Assign Author
2+
3+
[![CI Status](https://github.com/technote-space/assign-author/workflows/CI/badge.svg)](https://github.com/technote-space/assign-author/actions)
4+
[![codecov](https://codecov.io/gh/technote-space/assign-author/branch/master/graph/badge.svg)](https://codecov.io/gh/technote-space/assign-author)
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+
*Read this in other languages: [English](README.md), [日本語](README.ja.md).*
9+
10+
`GitHub Actions` to assign author to issue or PR.
11+
12+
## Table of Contents
13+
14+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
15+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
16+
<details>
17+
<summary>Details</summary>
18+
19+
- [Screenshot](#screenshot)
20+
- [Installation](#installation)
21+
- [Action event details](#action-event-details)
22+
- [Target events](#target-events)
23+
- [Example repositories using this Action](#example-repositories-using-this-action)
24+
- [Author](#author)
25+
26+
</details>
27+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
28+
29+
## Screenshot
30+
![GitHub Action](https://raw.githubusercontent.com/technote-space/assign-author/images/screenshot.gif)
31+
32+
## Installation
33+
1. Setup workflow
34+
e.g. `.github/workflows/pull_request.yml`
35+
```yaml
36+
on:
37+
pull_request:
38+
types: [opened]
39+
name: Pull Request
40+
jobs:
41+
assignAuthor:
42+
name: Assign author to PR
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Assign author to PR
46+
uses: technote-space/assign-author@v1
47+
```
48+
e.g. `.github/workflows/issues.yml`
49+
```yaml
50+
on:
51+
issues:
52+
types: [opened]
53+
name: Issues
54+
jobs:
55+
assignAuthor:
56+
name: Assign author to issue
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Assign author to issue
60+
uses: technote-space/assign-author@v1
61+
```
62+
63+
## Action event details
64+
### Target events
65+
| eventName | action |
66+
|:---:|:---:|
67+
|pull_request|opened|
68+
|pull_request|rerequested|
69+
|issues|opened|
70+
|issues|rerequested|
71+
72+
## Example repositories using this Action
73+
- [Release GitHub Actions](https://github.com/technote-space/release-github-actions)
74+
- [issue-opened.yml](https://github.com/technote-space/release-github-actions/blob/master/.github/workflows/issue-opened.yml)
75+
- [pr-opened.yml](https://github.com/technote-space/release-github-actions/blob/master/.github/workflows/pr-opened.yml)
76+
- [Auto card labeler](https://github.com/technote-space/auto-card-labeler)
77+
- [issue-opened.yml](https://github.com/technote-space/auto-card-labeler/blob/master/.github/workflows/issue-opened.yml)
78+
- [pr-opened.yml](https://github.com/technote-space/auto-card-labeler/blob/master/.github/workflows/pr-opened.yml)
79+
- [Assign Author](https://github.com/technote-space/assign-author)
80+
- [issue-opened.yml](https://github.com/technote-space/assign-author/blob/master/.github/workflows/issue-opened.yml)
81+
- [pr-opened.yml](https://github.com/technote-space/assign-author/blob/master/.github/workflows/pr-opened.yml)
82+
- [TOC Generator](https://github.com/technote-space/toc-generator)
83+
- [issue-opened.yml](https://github.com/technote-space/toc-generator/blob/master/.github/workflows/issue-opened.yml)
84+
- [pr-opened.yml](https://github.com/technote-space/toc-generator/blob/master/.github/workflows/pr-opened.yml)
85+
- [Package Version Check Action](https://github.com/technote-space/package-version-check-action)
86+
- [issue-opened.yml](https://github.com/technote-space/package-version-check-action/blob/master/.github/workflows/issue-opened.yml)
87+
- [pr-opened.yml](https://github.com/technote-space/package-version-check-action/blob/master/.github/workflows/pr-opened.yml)
88+
- [Get Diff Action](https://github.com/technote-space/get-diff-action)
89+
- [issue-opened.yml](https://github.com/technote-space/get-diff-action/blob/master/.github/workflows/issue-opened.yml)
90+
- [pr-opened.yml](https://github.com/technote-space/get-diff-action/blob/master/.github/workflows/pr-opened.yml)
91+
- [Create Project Card Action](https://github.com/technote-space/create-project-card-action)
92+
- [issue-opened.yml](https://github.com/technote-space/create-project-card-action/blob/master/.github/workflows/issue-opened.yml)
93+
- [pr-opened.yml](https://github.com/technote-space/create-project-card-action/blob/master/.github/workflows/pr-opened.yml)
94+
- [Get git comment action](https://github.com/technote-space/get-git-comment-action)
95+
- [issue-opened.yml](https://github.com/technote-space/get-git-comment-action/blob/master/.github/workflows/issue-opened.yml)
96+
- [pr-opened.yml](https://github.com/technote-space/get-git-comment-action/blob/master/.github/workflows/pr-opened.yml)
97+
98+
## Author
99+
[GitHub (Technote)](https://github.com/technote-space)
100+
[Blog](https://technote.space)

action.yml

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

build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"owner":"technote-space","repo":"assign-author","sha":"b1c85aba5db8cb1ff0f420fed8220a7a96af7b44","ref":"refs/tags/test/v1.3.1.53748159","tagName":"test/v1.3.1.53748159","branch":"releases/v1","tags":["test/v1.3.1.53748159","test/v1.3.1","test/v1.3","test/v1"],"updated_at":"2020-03-11T15:47:37.540Z"}

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', 'reopened'],
5+
'pull_request': ['opened', 'reopened'],
6+
};

lib/main.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+
Object.defineProperty(exports, "__esModule", { value: true });
12+
const path_1 = require("path");
13+
const core_1 = require("@actions/core");
14+
const context_1 = require("@actions/github/lib/context");
15+
const filter_github_action_1 = require("@technote-space/filter-github-action");
16+
const github_action_helper_1 = require("@technote-space/github-action-helper");
17+
const process_1 = require("./process");
18+
const constant_1 = require("./constant");
19+
const run = () => __awaiter(void 0, void 0, void 0, function* () {
20+
const logger = new github_action_helper_1.Logger();
21+
const context = new context_1.Context();
22+
github_action_helper_1.ContextHelper.showActionInfo(path_1.resolve(__dirname, '..'), logger, context);
23+
if (!filter_github_action_1.isTargetEvent(constant_1.TARGET_EVENTS, context)) {
24+
logger.info('This is not target event.');
25+
return;
26+
}
27+
yield process_1.execute(logger, github_action_helper_1.Utils.getOctokit(), context);
28+
});
29+
run().catch(error => {
30+
console.log(error);
31+
core_1.setFailed(error.message);
32+
});

lib/process.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
Object.defineProperty(exports, "__esModule", { value: true });
12+
const context_1 = require("./utils/context");
13+
const github_1 = require("./utils/github");
14+
exports.execute = (logger, octokit, context) => __awaiter(void 0, void 0, void 0, function* () { return github_1.addAssignees(context_1.getAssignees(context), octokit, logger, context); });

lib/utils/context.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const github_action_helper_1 = require("@technote-space/github-action-helper");
4+
const getCurrentAssignees = (context) => {
5+
if ('issues' === context.eventName) {
6+
return context.payload.issue && 'assignees' in context.payload.issue ? context.payload.issue.assignees.map(assignee => assignee.login) : false;
7+
}
8+
if ('pull_request' === context.eventName) {
9+
return context.payload.pull_request && 'assignees' in context.payload.pull_request ? context.payload.pull_request.assignees.map(assignee => assignee.login) : false;
10+
}
11+
return false;
12+
};
13+
exports.getAssignees = (context) => {
14+
const sender = github_action_helper_1.ContextHelper.getSender(context);
15+
if (false === sender) {
16+
return false;
17+
}
18+
const assignees = getCurrentAssignees(context);
19+
if (false === assignees) {
20+
return false;
21+
}
22+
if (assignees.includes(sender)) {
23+
return [];
24+
}
25+
return [sender];
26+
};

lib/utils/github.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
Object.defineProperty(exports, "__esModule", { value: true });
12+
exports.addAssignees = (assignees, octokit, logger, context) => __awaiter(void 0, void 0, void 0, function* () {
13+
if (false === assignees) {
14+
logger.warn('Invalid target.');
15+
return;
16+
}
17+
logger.info('Adding assignees');
18+
logger.info(assignees);
19+
if (!assignees.length) {
20+
logger.info('do nothing...');
21+
return;
22+
}
23+
try {
24+
yield octokit.issues.addAssignees({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
'issue_number': context.issue.number,
28+
assignees: assignees,
29+
});
30+
}
31+
catch (error) {
32+
if ('Resource not accessible by integration' === error.message) {
33+
logger.warn(error.message);
34+
}
35+
else {
36+
throw error;
37+
}
38+
}
39+
});

0 commit comments

Comments
 (0)