Skip to content

Commit 0cc98f7

Browse files
Merge pull request #146 from technote-space/release/v1.2.6
release/v1.2.6
2 parents 5cd64b3 + e9c2600 commit 0cc98f7

File tree

7 files changed

+1336
-1565
lines changed

7 files changed

+1336
-1565
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ indent_size = 4
1111
[{*.json,*.yml}]
1212
indent_style = space
1313
indent_size = 2
14+
15+
[*.md]
16+
trim_trailing_whitespace = false

__tests__/utils/github.test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { addAssignees } from '../../src/utils/github';
99
describe('addAssignees', () => {
1010
disableNetConnect(nock);
1111

12-
const logger = new Logger();
12+
const logger = new Logger();
13+
const octokit = new GitHub('test-token');
1314

1415
it('should do nothing 1', async() => {
1516
const fn = jest.fn();
@@ -20,7 +21,7 @@ describe('addAssignees', () => {
2021
return body;
2122
});
2223

23-
await addAssignees(false, new GitHub(''), logger, getContext({
24+
await addAssignees(false, octokit, logger, getContext({
2425
repo: {
2526
owner: 'hello',
2627
repo: 'world',
@@ -39,7 +40,7 @@ describe('addAssignees', () => {
3940
return body;
4041
});
4142

42-
await addAssignees([], new GitHub(''), logger, getContext({
43+
await addAssignees([], octokit, logger, getContext({
4344
repo: {
4445
owner: 'hello',
4546
repo: 'world',
@@ -50,8 +51,8 @@ describe('addAssignees', () => {
5051
});
5152

5253
it('should do nothing 3', async() => {
53-
const fn1 = jest.fn();
54-
const fn2 = jest.fn();
54+
const fn1 = jest.fn();
55+
const fn2 = jest.fn();
5556
const mockStdout = spyOnStdout();
5657
nock('https://api.github.com')
5758
.post('/repos/hello/world/issues/1/assignees', body => {
@@ -67,7 +68,7 @@ describe('addAssignees', () => {
6768

6869
await addAssignees([
6970
'test',
70-
], new GitHub(''), logger, getContext({
71+
], octokit, logger, getContext({
7172
repo: {
7273
owner: 'hello',
7374
repo: 'world',
@@ -84,7 +85,7 @@ describe('addAssignees', () => {
8485
});
8586

8687
it('should do nothing 4', async() => {
87-
const fn = jest.fn();
88+
const fn = jest.fn();
8889
const mockStdout = spyOnStdout();
8990
nock('https://api.github.com')
9091
.post('/repos/hello/world/issues/1/assignees', body => {
@@ -99,7 +100,7 @@ describe('addAssignees', () => {
99100

100101
await expect(addAssignees([
101102
'test',
102-
], new GitHub(''), logger, getContext({
103+
], octokit, logger, getContext({
103104
repo: {
104105
owner: 'hello',
105106
repo: 'world',
@@ -130,7 +131,7 @@ describe('addAssignees', () => {
130131

131132
await addAssignees([
132133
'test',
133-
], new GitHub(''), logger, getContext({
134+
], octokit, logger, getContext({
134135
repo: {
135136
owner: 'hello',
136137
repo: 'world',

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
name: Assign Author
2+
23
description: GitHub actions to assign author to issue or PR.
4+
35
author: technote-space
6+
47
inputs:
58
GITHUB_TOKEN:
69
description: Secret GitHub API token to use for making API requests.
710
required: true
11+
812
branding:
913
icon: 'user-plus'
1014
color: 'orange'
15+
1116
runs:
1217
using: node12
1318
main: lib/main.js

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/assign-author",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "GitHub actions to assign author to issue or PR.",
55
"author": "Technote <technote.space@gmail.com> (https://technote.space)",
66
"license": "MIT",
@@ -19,32 +19,32 @@
1919
},
2020
"main": "lib/main.js",
2121
"dependencies": {
22-
"@actions/core": "^1.2.0",
23-
"@actions/github": "^2.0.0",
24-
"@technote-space/filter-github-action": "^0.1.12",
25-
"@technote-space/github-action-helper": "^0.6.25"
22+
"@actions/core": "^1.2.2",
23+
"@actions/github": "^2.1.0",
24+
"@technote-space/filter-github-action": "^0.1.17",
25+
"@technote-space/github-action-helper": "^0.8.2"
2626
},
2727
"devDependencies": {
28-
"@technote-space/github-action-test-helper": "^0.0.27",
29-
"@types/jest": "^24.0.23",
30-
"@types/node": "^12.12.18",
31-
"@typescript-eslint/eslint-plugin": "^2.11.0",
32-
"@typescript-eslint/parser": "^2.11.0",
33-
"eslint": "^6.7.2",
34-
"jest": "^24.9.0",
35-
"jest-circus": "^24.9.0",
36-
"nock": "^11.7.0",
37-
"ts-jest": "^24.2.0",
38-
"typescript": "^3.7.3"
28+
"@technote-space/github-action-test-helper": "^0.1.4",
29+
"@types/jest": "^24.9.1",
30+
"@types/node": "^13.5.0",
31+
"@typescript-eslint/eslint-plugin": "^2.17.0",
32+
"@typescript-eslint/parser": "^2.17.0",
33+
"eslint": "^6.8.0",
34+
"jest": "^25.1.0",
35+
"jest-circus": "^25.1.0",
36+
"nock": "^11.7.2",
37+
"ts-jest": "^25.0.0",
38+
"typescript": "^3.7.5"
3939
},
4040
"publishConfig": {
4141
"access": "public"
4242
},
4343
"scripts": {
4444
"build": "tsc",
4545
"test": "yarn lint && yarn cover",
46-
"lint": "eslint src/**/**/*.ts __tests__/**/**/*.ts",
47-
"lint:fix": "eslint --fix src/**/**/*.ts __tests__/**/**/*.ts",
46+
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts'",
47+
"lint:fix": "eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
4848
"cover": "jest --coverage",
4949
"update": "ncu -u && yarn install && yarn upgrade && yarn audit"
5050
}

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import path from 'path';
2-
import { setFailed, getInput } from '@actions/core';
2+
import { setFailed } from '@actions/core';
33
import { context, GitHub } from '@actions/github';
44
import { isTargetEvent } from '@technote-space/filter-github-action';
5-
import { Logger, ContextHelper } from '@technote-space/github-action-helper';
5+
import { Logger, ContextHelper, Utils } from '@technote-space/github-action-helper';
66
import { getAssignees } from './utils/context';
77
import { addAssignees } from './utils/github';
88
import { TARGET_EVENTS } from './constant';
@@ -19,7 +19,7 @@ async function run(): Promise<void> {
1919
return;
2020
}
2121

22-
await addAssignees(getAssignees(context), new GitHub(getInput('GITHUB_TOKEN', {required: true})), logger, context);
22+
await addAssignees(getAssignees(context), new GitHub(Utils.getAccessToken(true)), logger, context);
2323
}
2424

2525
run().catch(error => setFailed(error.message));

src/utils/context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ const getCurrentAssignees = (context: Context): string[] | false => {
55
if ('issues' === context.eventName) {
66
return context.payload.issue && 'assignees' in context.payload.issue ? context.payload.issue.assignees.map(assignee => assignee.login) : false;
77
}
8+
89
if ('pull_request' === context.eventName) {
910
return context.payload.pull_request && 'assignees' in context.payload.pull_request ? context.payload.pull_request.assignees.map(assignee => assignee.login) : false;
1011
}
12+
1113
return false;
1214
};
1315

0 commit comments

Comments
 (0)