Skip to content

Commit 6aa1a5b

Browse files
committed
feat: init
1 parent ba595b0 commit 6aa1a5b

File tree

6 files changed

+227
-66
lines changed

6 files changed

+227
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
## v1.0.0
1212

13-
`2021.xx.xx`
13+
`2021.12.17`
1414

1515
- 🎉 Init.

README.md

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,40 @@
1-
<p align="center">
2-
<a href="">
3-
<img width="140" src="https://avatars.githubusercontent.com/u/73879334?s=200&v=4" />
4-
</a>
5-
</p>
1+
# 👷🏻‍♂️ Check Issue Reference
62

7-
<h1 align="center">Action TypeScript Template</h1>
8-
<div align="center">
9-
A typescript template for rapid development of GitHub actions.
10-
</div>
11-
12-
![](https://img.shields.io/github/workflow/status/actions-cool/action-ts-template/CI?style=flat-square)
13-
[![](https://img.shields.io/badge/marketplace-action--ts--template-blueviolet?style=flat-square)](https://github.com/marketplace/actions/action-ts-template)
14-
[![](https://img.shields.io/github/v/release/actions-cool/action-ts-template?style=flat-square&color=orange)](https://github.com/actions-cool/action-ts-template/releases)
3+
![](https://img.shields.io/github/workflow/status/actions-cool/check-issue-ref/CI?style=flat-square)
4+
[![](https://img.shields.io/badge/marketplace-check--issue--ref-blueviolet?style=flat-square)](https://github.com/marketplace/actions/check-issue-ref)
5+
[![](https://img.shields.io/github/v/release/actions-cool/check-issue-ref?style=flat-square&color=orange)](https://github.com/actions-cool/check-issue-ref/releases)
156

167
## 🚀 How to use?
178

18-
![](https://github.com/actions-cool/resources/blob/main/image/template.png?raw=true)
9+
```yml
10+
name: Check Issue Reference
1911

20-
## 📒 Catalog Introduction
12+
on:
13+
issues:
14+
types: [opened]
2115

22-
```
23-
├── .github/workflows/ The CI for make sure it is packaged correctly
24-
├── dist Package the generated Aciton execution code
25-
├── src Component home directory
26-
│ └── main.ts Your code
27-
├── .eslintrc.js Eslint config
28-
├── .prettierrc.js Prettier config
29-
├── action.yml Action config
30-
└── tsconfig.json TypeScript config
31-
```
16+
jobs:
17+
check-reference:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions-cool/check-issue-ref@v1
21+
id: check
3222

33-
The rest of the documents can be consulted by yourself.
23+
- run: echo ref ${{ steps.check.outputs.result }}
24+
```
3425
35-
## 🤖 Command introduction
26+
### outputs
3627
37-
| Name | Desc |
38-
| -- | -- |
39-
| build | ts build |
40-
| format | prettier write |
41-
| lint | eslint check |
42-
| package | action build for release |
43-
| all | npm all |
28+
- `result`
29+
- `0`: no ref
30+
- other number: the issue open ref
4431

4532
## ⚡ Feedback
4633

4734
You are very welcome to try it out and put forward your comments. You can use the following methods:
4835

49-
- Report bugs or consult with [Issue](https://github.com/actions-cool/action-ts-template/issues)
50-
- Submit [Pull Request](https://github.com/actions-cool/action-ts-template/pulls) to improve the code of `action-ts-template`
36+
- Report bugs or consult with [Issue](https://github.com/actions-cool/check-issue-ref/issues)
37+
- Submit [Pull Request](https://github.com/actions-cool/check-issue-refe/pulls) to improve the code of `check-issue-ref`
5138

5239
也欢迎加入 钉钉交流群
5340

action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
2-
name: 'Action TS Template'
3-
description: 'A typescript template for rapid development of GitHub actions.'
2+
name: 'Check Issue Reference'
3+
description: 'Check a issue whether create by reference.'
44
author: 'xrkffgg'
55

6+
# https://actions-cool.github.io/github-action-branding/
67
branding:
7-
# https://actions-cool.github.io/github-action-branding/
8-
icon: 'file'
9-
color: 'blue'
8+
icon: 'git-branch'
9+
color: 'green'
1010

1111
inputs:
1212
token:
1313
description: Secret GitHub API token to use for making API requests.
1414
default: ${{ github.token }}
1515
required: true
1616

17-
#outputs:
18-
# result:
19-
# description: action result
17+
outputs:
18+
result:
19+
description: issue ref
2020

2121
runs:
2222
using: 'node12'

dist/index.js

Lines changed: 162 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4886,7 +4886,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
48864886
var endpoint = __nccwpck_require__(2061);
48874887
var universalUserAgent = __nccwpck_require__(6393);
48884888
var isPlainObject = __nccwpck_require__(7080);
4889-
var nodeFetch = _interopDefault(__nccwpck_require__(9917));
4889+
var nodeFetch = _interopDefault(__nccwpck_require__(859));
48904890
var requestError = __nccwpck_require__(9220);
48914891

48924892
const VERSION = "5.6.2";
@@ -5081,6 +5081,135 @@ exports.Octokit = Octokit;
50815081
//# sourceMappingURL=index.js.map
50825082

50835083

5084+
/***/ }),
5085+
5086+
/***/ 6943:
5087+
/***/ ((__unused_webpack_module, exports) => {
5088+
5089+
"use strict";
5090+
5091+
5092+
Object.defineProperty(exports, "__esModule", ({
5093+
value: true
5094+
}));
5095+
exports.checkPermission = void 0;
5096+
5097+
var checkPermission = function checkPermission(require, permission) {
5098+
/**
5099+
* 有权限返回 true
5100+
*/
5101+
var permissions = ['read', 'write', 'admin'];
5102+
var requireNo = permissions.indexOf(require);
5103+
var permissionNo = permissions.indexOf(permission);
5104+
return requireNo <= permissionNo;
5105+
};
5106+
5107+
exports.checkPermission = checkPermission;
5108+
5109+
/***/ }),
5110+
5111+
/***/ 9983:
5112+
/***/ ((__unused_webpack_module, exports) => {
5113+
5114+
"use strict";
5115+
5116+
5117+
Object.defineProperty(exports, "__esModule", ({
5118+
value: true
5119+
}));
5120+
exports.dealStringToArr = void 0;
5121+
5122+
var dealStringToArr = function dealStringToArr(para) {
5123+
/**
5124+
* in 'x1,x2,x3'
5125+
* out ['x1','x2','x3']
5126+
*/
5127+
var arr = [];
5128+
5129+
if (para) {
5130+
var paraArr = para.split(',');
5131+
paraArr.forEach(function (it) {
5132+
if (it.trim()) {
5133+
arr.push(it.trim());
5134+
}
5135+
});
5136+
}
5137+
5138+
return arr;
5139+
};
5140+
5141+
exports.dealStringToArr = dealStringToArr;
5142+
5143+
/***/ }),
5144+
5145+
/***/ 2369:
5146+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5147+
5148+
"use strict";
5149+
5150+
5151+
Object.defineProperty(exports, "__esModule", ({
5152+
value: true
5153+
}));
5154+
5155+
var _check = __nccwpck_require__(6943);
5156+
5157+
Object.keys(_check).forEach(function (key) {
5158+
if (key === "default" || key === "__esModule") return;
5159+
if (key in exports && exports[key] === _check[key]) return;
5160+
Object.defineProperty(exports, key, {
5161+
enumerable: true,
5162+
get: function get() {
5163+
return _check[key];
5164+
}
5165+
});
5166+
});
5167+
5168+
var _deal = __nccwpck_require__(9983);
5169+
5170+
Object.keys(_deal).forEach(function (key) {
5171+
if (key === "default" || key === "__esModule") return;
5172+
if (key in exports && exports[key] === _deal[key]) return;
5173+
Object.defineProperty(exports, key, {
5174+
enumerable: true,
5175+
get: function get() {
5176+
return _deal[key];
5177+
}
5178+
});
5179+
});
5180+
5181+
var _thanks = __nccwpck_require__(9642);
5182+
5183+
Object.keys(_thanks).forEach(function (key) {
5184+
if (key === "default" || key === "__esModule") return;
5185+
if (key in exports && exports[key] === _thanks[key]) return;
5186+
Object.defineProperty(exports, key, {
5187+
enumerable: true,
5188+
get: function get() {
5189+
return _thanks[key];
5190+
}
5191+
});
5192+
});
5193+
5194+
/***/ }),
5195+
5196+
/***/ 9642:
5197+
/***/ ((__unused_webpack_module, exports) => {
5198+
5199+
"use strict";
5200+
5201+
5202+
Object.defineProperty(exports, "__esModule", ({
5203+
value: true
5204+
}));
5205+
exports.THANKS_MAIN = exports.THANKS_FOOTER = exports.THANKS = void 0;
5206+
var THANKS_MAIN = "<<< \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 >>>\n\u2502 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2502\n\u2502 \u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2502\n\u2502 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557 \u2502\n\u2502 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557 \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2502\n\u2502 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2502\n\u2502 \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u2502\n\u2502 \u2502\n\u2502 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2502\n\u2502 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2502\n\u2502 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2502\n\u2502 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2502\n\u2502 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2502\n\u2502 \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u2502";
5207+
exports.THANKS_MAIN = THANKS_MAIN;
5208+
var THANKS_FOOTER = "\n<<< \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 by xrkffgg >>>";
5209+
exports.THANKS_FOOTER = THANKS_FOOTER;
5210+
var THANKS = THANKS_MAIN + THANKS_FOOTER;
5211+
exports.THANKS = THANKS;
5212+
50845213
/***/ }),
50855214

50865215
/***/ 6996:
@@ -5334,7 +5463,7 @@ exports.isPlainObject = isPlainObject;
53345463

53355464
/***/ }),
53365465

5337-
/***/ 9917:
5466+
/***/ 859:
53385467
/***/ ((module, exports, __nccwpck_require__) => {
53395468

53405469
"use strict";
@@ -6482,7 +6611,7 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
64826611
});
64836612

64846613
const INTERNALS$2 = Symbol('Request internals');
6485-
const URL = whatwgUrl.URL;
6614+
const URL = Url.URL || whatwgUrl.URL;
64866615

64876616
// fix an issue where "format", "parse" aren't a named export for node <10
64886617
const parse_url = Url.parse;
@@ -9607,19 +9736,42 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
96079736
const core = __importStar(__nccwpck_require__(3419));
96089737
const github = __importStar(__nccwpck_require__(1840));
96099738
const rest_1 = __nccwpck_require__(5744);
9739+
const actions_util_1 = __nccwpck_require__(2369);
96109740
function run() {
9741+
var _a, _b;
96119742
return __awaiter(this, void 0, void 0, function* () {
96129743
try {
96139744
const token = core.getInput('token');
9614-
// API: https://actions-cool.github.io/octokit-rest/
96159745
const octokit = new rest_1.Octokit({ auth: `token ${token}` });
96169746
const context = github.context;
9617-
const username = context.actor;
9618-
// This is a test
9619-
yield octokit.users.getByUsername({
9620-
username,
9621-
});
9622-
core.info(`[Action Query] Query ${username} success!`);
9747+
const { owner, repo } = context.repo;
9748+
if (context.eventName === 'issues') {
9749+
const issue_number = context.payload.issue.number;
9750+
// 先查 100 个
9751+
const { data: events } = yield octokit.issues.listEventsForTimeline({
9752+
owner,
9753+
repo,
9754+
issue_number,
9755+
per_page: 100,
9756+
});
9757+
let result = 0;
9758+
if (events && events.length) {
9759+
for (const event of events) {
9760+
if (event.event === 'cross-referenced') {
9761+
result = (_b = (_a = event.source) === null || _a === void 0 ? void 0 : _a.issue) === null || _b === void 0 ? void 0 : _b.number;
9762+
}
9763+
break;
9764+
}
9765+
}
9766+
if (result) {
9767+
core.info(`[Action] issue ${issue_number} refer issue ${result}`);
9768+
}
9769+
core.setOutput('result', result);
9770+
}
9771+
else {
9772+
core.setFailed(`This Action only support "issues" !`);
9773+
}
9774+
core.info(actions_util_1.THANKS);
96239775
}
96249776
catch (error) {
96259777
core.setFailed(error.message);

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "action-ts-template",
2+
"name": "check-issue-ref",
33
"private": true,
4-
"description": "A typescript template for rapid development of GitHub actions.",
4+
"description": "Check a issue whether create by reference.",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/actions-cool/action-ts-template",
@@ -22,7 +22,8 @@
2222
"dependencies": {
2323
"@actions/core": "^1.2.6",
2424
"@actions/github": "^4.0.0",
25-
"@octokit/rest": "^18.0.14"
25+
"@octokit/rest": "^18.0.14",
26+
"actions-util": "^1.1.4"
2627
},
2728
"devDependencies": {
2829
"@typescript-eslint/parser": "^4.15.2",

0 commit comments

Comments
 (0)