Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Dec 17, 2021
1 parent ba595b0 commit 6aa1a5b
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 66 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

## v1.0.0

`2021.xx.xx`
`2021.12.17`

- 🎉 Init.
59 changes: 23 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,40 @@
<p align="center">
<a href="">
<img width="140" src="https://avatars.githubusercontent.com/u/73879334?s=200&v=4" />
</a>
</p>
# 👷🏻‍♂️ Check Issue Reference

<h1 align="center">Action TypeScript Template</h1>
<div align="center">
A typescript template for rapid development of GitHub actions.
</div>

![](https://img.shields.io/github/workflow/status/actions-cool/action-ts-template/CI?style=flat-square)
[![](https://img.shields.io/badge/marketplace-action--ts--template-blueviolet?style=flat-square)](https://github.com/marketplace/actions/action-ts-template)
[![](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)
![](https://img.shields.io/github/workflow/status/actions-cool/check-issue-ref/CI?style=flat-square)
[![](https://img.shields.io/badge/marketplace-check--issue--ref-blueviolet?style=flat-square)](https://github.com/marketplace/actions/check-issue-ref)
[![](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)

## 🚀 How to use?

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

## 📒 Catalog Introduction
on:
issues:
types: [opened]

```
├── .github/workflows/ The CI for make sure it is packaged correctly
├── dist Package the generated Aciton execution code
├── src Component home directory
│ └── main.ts Your code
├── .eslintrc.js Eslint config
├── .prettierrc.js Prettier config
├── action.yml Action config
└── tsconfig.json TypeScript config
```
jobs:
check-reference:
runs-on: ubuntu-latest
steps:
- uses: actions-cool/check-issue-ref@v1
id: check

The rest of the documents can be consulted by yourself.
- run: echo ref ${{ steps.check.outputs.result }}
```
## 🤖 Command introduction
### outputs
| Name | Desc |
| -- | -- |
| build | ts build |
| format | prettier write |
| lint | eslint check |
| package | action build for release |
| all | npm all |
- `result`
- `0`: no ref
- other number: the issue open ref

## ⚡ Feedback

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

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

也欢迎加入 钉钉交流群

Expand Down
16 changes: 8 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
name: 'Action TS Template'
description: 'A typescript template for rapid development of GitHub actions.'
name: 'Check Issue Reference'
description: 'Check a issue whether create by reference.'
author: 'xrkffgg'

# https://actions-cool.github.io/github-action-branding/
branding:
# https://actions-cool.github.io/github-action-branding/
icon: 'file'
color: 'blue'
icon: 'git-branch'
color: 'green'

inputs:
token:
description: Secret GitHub API token to use for making API requests.
default: ${{ github.token }}
required: true

#outputs:
# result:
# description: action result
outputs:
result:
description: issue ref

runs:
using: 'node12'
Expand Down
172 changes: 162 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4886,7 +4886,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
var endpoint = __nccwpck_require__(2061);
var universalUserAgent = __nccwpck_require__(6393);
var isPlainObject = __nccwpck_require__(7080);
var nodeFetch = _interopDefault(__nccwpck_require__(9917));
var nodeFetch = _interopDefault(__nccwpck_require__(859));
var requestError = __nccwpck_require__(9220);

const VERSION = "5.6.2";
Expand Down Expand Up @@ -5081,6 +5081,135 @@ exports.Octokit = Octokit;
//# sourceMappingURL=index.js.map


/***/ }),

/***/ 6943:
/***/ ((__unused_webpack_module, exports) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.checkPermission = void 0;

var checkPermission = function checkPermission(require, permission) {
/**
* 有权限返回 true
*/
var permissions = ['read', 'write', 'admin'];
var requireNo = permissions.indexOf(require);
var permissionNo = permissions.indexOf(permission);
return requireNo <= permissionNo;
};

exports.checkPermission = checkPermission;

/***/ }),

/***/ 9983:
/***/ ((__unused_webpack_module, exports) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.dealStringToArr = void 0;

var dealStringToArr = function dealStringToArr(para) {
/**
* in 'x1,x2,x3'
* out ['x1','x2','x3']
*/
var arr = [];

if (para) {
var paraArr = para.split(',');
paraArr.forEach(function (it) {
if (it.trim()) {
arr.push(it.trim());
}
});
}

return arr;
};

exports.dealStringToArr = dealStringToArr;

/***/ }),

/***/ 2369:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
value: true
}));

var _check = __nccwpck_require__(6943);

Object.keys(_check).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _check[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _check[key];
}
});
});

var _deal = __nccwpck_require__(9983);

Object.keys(_deal).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _deal[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _deal[key];
}
});
});

var _thanks = __nccwpck_require__(9642);

Object.keys(_thanks).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _thanks[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _thanks[key];
}
});
});

/***/ }),

/***/ 9642:
/***/ ((__unused_webpack_module, exports) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.THANKS_MAIN = exports.THANKS_FOOTER = exports.THANKS = void 0;
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";
exports.THANKS_MAIN = THANKS_MAIN;
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 >>>";
exports.THANKS_FOOTER = THANKS_FOOTER;
var THANKS = THANKS_MAIN + THANKS_FOOTER;
exports.THANKS = THANKS;

/***/ }),

/***/ 6996:
Expand Down Expand Up @@ -5334,7 +5463,7 @@ exports.isPlainObject = isPlainObject;

/***/ }),

/***/ 9917:
/***/ 859:
/***/ ((module, exports, __nccwpck_require__) => {

"use strict";
Expand Down Expand Up @@ -6482,7 +6611,7 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
});

const INTERNALS$2 = Symbol('Request internals');
const URL = whatwgUrl.URL;
const URL = Url.URL || whatwgUrl.URL;

// fix an issue where "format", "parse" aren't a named export for node <10
const parse_url = Url.parse;
Expand Down Expand Up @@ -9607,19 +9736,42 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(3419));
const github = __importStar(__nccwpck_require__(1840));
const rest_1 = __nccwpck_require__(5744);
const actions_util_1 = __nccwpck_require__(2369);
function run() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
try {
const token = core.getInput('token');
// API: https://actions-cool.github.io/octokit-rest/
const octokit = new rest_1.Octokit({ auth: `token ${token}` });
const context = github.context;
const username = context.actor;
// This is a test
yield octokit.users.getByUsername({
username,
});
core.info(`[Action Query] Query ${username} success!`);
const { owner, repo } = context.repo;
if (context.eventName === 'issues') {
const issue_number = context.payload.issue.number;
// 先查 100 个
const { data: events } = yield octokit.issues.listEventsForTimeline({
owner,
repo,
issue_number,
per_page: 100,
});
let result = 0;
if (events && events.length) {
for (const event of events) {
if (event.event === 'cross-referenced') {
result = (_b = (_a = event.source) === null || _a === void 0 ? void 0 : _a.issue) === null || _b === void 0 ? void 0 : _b.number;
}
break;
}
}
if (result) {
core.info(`[Action] issue ${issue_number} refer issue ${result}`);
}
core.setOutput('result', result);
}
else {
core.setFailed(`This Action only support "issues" !`);
}
core.info(actions_util_1.THANKS);
}
catch (error) {
core.setFailed(error.message);
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "action-ts-template",
"name": "check-issue-ref",
"private": true,
"description": "A typescript template for rapid development of GitHub actions.",
"description": "Check a issue whether create by reference.",
"repository": {
"type": "git",
"url": "https://github.com/actions-cool/action-ts-template",
Expand All @@ -22,7 +22,8 @@
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@octokit/rest": "^18.0.14"
"@octokit/rest": "^18.0.14",
"actions-util": "^1.1.4"
},
"devDependencies": {
"@typescript-eslint/parser": "^4.15.2",
Expand Down
Loading

0 comments on commit 6aa1a5b

Please sign in to comment.