Skip to content

Commit 97c6aa8

Browse files
committed
👷 ci(action): Done
1 parent bd5a68d commit 97c6aa8

10 files changed

Lines changed: 486 additions & 19 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: deploy website preview
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
pull_request_target:
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: ./
14+
id: commit-comment
15+
with:
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
body: |
18+
Website preview for commit ${GITHUB_SHA} at ${GITHUB_RUN_ATTEMPT}
19+
- [Preview](https://h7ml.github.io/commit-comment)
20+
- [Source code](https://github.com/h7ml/commit-comment)

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ node_modules/
1414
.eslintcache
1515
.changeset/pre.json
1616

17-
dist/
1817
coverage/
1918
release/
2019
output/

LICENSE

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

action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'commit-comment'
2+
description: 'A GitHub Action to commit comment'
3+
author: 'h7ml <h7ml@qq.com>'
4+
5+
branding:
6+
icon: 'message-circle'
7+
color: 'green'
8+
version: 'v1.0.0'
9+
author: 'h7ml'
10+
11+
inputs:
12+
token:
13+
description: Secret GitHub API token to use for making API requests.
14+
default: ${{ github.token }}
15+
required: true
16+
body:
17+
description: Comment content.
18+
required: true
19+
20+
outputs:
21+
comment_id:
22+
description: The ID of the comment that was created.
23+
24+
runs:
25+
using: node16
26+
main: './dist/lib/index.js'

dist/es/index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var __async = (__this, __arguments, generator) => {
2+
return new Promise((resolve, reject) => {
3+
var fulfilled = (value) => {
4+
try {
5+
step(generator.next(value));
6+
} catch (e) {
7+
reject(e);
8+
}
9+
};
10+
var rejected = (value) => {
11+
try {
12+
step(generator.throw(value));
13+
} catch (e) {
14+
reject(e);
15+
}
16+
};
17+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18+
step((generator = generator.apply(__this, __arguments)).next());
19+
});
20+
};
21+
22+
// src/index.ts
23+
import { getInput, setFailed, setOutput } from "@actions/core";
24+
import { Octokit } from "@octokit/rest";
25+
import { context } from "@actions/github";
26+
function run() {
27+
return __async(this, null, function* () {
28+
try {
29+
const token = getInput("token");
30+
const octokit = new Octokit({ auth: `token ${token}` });
31+
const { owner, repo } = context.repo;
32+
const body = getInput("body");
33+
const response = yield octokit.repos.createCommitComment({
34+
owner,
35+
repo,
36+
commit_sha: context.sha,
37+
body
38+
});
39+
const comment_id = response.data.id;
40+
setOutput("comment_id", comment_id);
41+
} catch (error) {
42+
setFailed(error.message);
43+
}
44+
});
45+
}
46+
run().catch((error) => {
47+
setFailed(error.message);
48+
});

dist/lib/index.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"use strict";
2+
var __async = (__this, __arguments, generator) => {
3+
return new Promise((resolve, reject) => {
4+
var fulfilled = (value) => {
5+
try {
6+
step(generator.next(value));
7+
} catch (e) {
8+
reject(e);
9+
}
10+
};
11+
var rejected = (value) => {
12+
try {
13+
step(generator.throw(value));
14+
} catch (e) {
15+
reject(e);
16+
}
17+
};
18+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19+
step((generator = generator.apply(__this, __arguments)).next());
20+
});
21+
};
22+
23+
// src/index.ts
24+
var import_core = require("@actions/core");
25+
var import_rest = require("@octokit/rest");
26+
var import_github = require("@actions/github");
27+
function run() {
28+
return __async(this, null, function* () {
29+
try {
30+
const token = (0, import_core.getInput)("token");
31+
const octokit = new import_rest.Octokit({ auth: `token ${token}` });
32+
const { owner, repo } = import_github.context.repo;
33+
const body = (0, import_core.getInput)("body");
34+
const response = yield octokit.repos.createCommitComment({
35+
owner,
36+
repo,
37+
commit_sha: import_github.context.sha,
38+
body
39+
});
40+
const comment_id = response.data.id;
41+
(0, import_core.setOutput)("comment_id", comment_id);
42+
} catch (error) {
43+
(0, import_core.setFailed)(error.message);
44+
}
45+
});
46+
}
47+
run().catch((error) => {
48+
(0, import_core.setFailed)(error.message);
49+
});

dist/types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
export { }

package.json

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
11
{
22
"name": "commit-comment",
3-
"version": "0.1.0",
4-
"types": "./dist/types/index.d.ts",
3+
"version": "1.0.0",
4+
"description": "A GitHub Action to commit comment",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/dext7r/commit-comment"
8+
},
9+
"homepage": "https://github.com/dext7r/commit-comment",
10+
"bugs": {
11+
"url": "https://github.com/dext7r/commit-comment/issues"
12+
},
13+
"keywords": [
14+
"github",
15+
"action",
16+
"commit",
17+
"comment"
18+
],
19+
"license": "MIT",
20+
"author": {
21+
"name": "h7ml",
22+
"email": "i@h7ml.cn",
23+
"url": "https://github.com/h7ml"
24+
},
25+
"sideEffects": [],
526
"main": "./dist/lib/index.js",
627
"module": "./dist/es/index.js",
28+
"types": "./dist/types/index.d.ts",
729
"scripts": {
8-
"prepare": "modern build && husky install",
9-
"dev": "modern dev",
1030
"build": "modern build",
1131
"build:watch": "modern build -w",
12-
"reset": "rimraf ./**/node_modules",
13-
"lint": "modern lint",
14-
"change": "modern change",
1532
"bump": "modern bump",
16-
"pre": "modern pre",
33+
"change": "modern change",
1734
"change-status": "modern change-status",
35+
"dev": "modern dev",
1836
"gen-release-note": "modern gen-release-note",
19-
"release": "modern release",
37+
"lint": "modern lint",
2038
"new": "modern new",
39+
"pre": "modern pre",
40+
"prepare": "modern build && husky install",
41+
"release": "modern release",
42+
"reset": "rimraf ./**/node_modules",
2143
"upgrade": "modern upgrade"
2244
},
2345
"lint-staged": {
@@ -29,19 +51,24 @@
2951
"node_modules/",
3052
"dist/"
3153
],
32-
"dependencies": {},
33-
"peerDependencies": {},
54+
"dependencies": {
55+
"@actions/core": "^1.10.1",
56+
"@actions/github": "^6.0.0",
57+
"@octokit/rest": "^20.1.0",
58+
"actions-util": "^1.1.4"
59+
},
3460
"devDependencies": {
35-
"@modern-js/module-tools": "2.49.2",
3661
"@modern-js/eslint-config": "2.49.2",
37-
"typescript": "~5.0.4",
62+
"@modern-js/module-tools": "2.49.2",
3863
"@types/node": "~16.11.7",
39-
"rimraf": "~3.0.2",
64+
"chalk": "^5.3.0",
65+
"husky": "~8.0.1",
4066
"lint-staged": "~13.1.0",
4167
"prettier": "~2.8.1",
42-
"husky": "~8.0.1"
68+
"rimraf": "~3.0.2",
69+
"simple-git": "^3.24.0",
70+
"typescript": "~5.0.4"
4371
},
44-
"sideEffects": [],
4572
"publishConfig": {
4673
"access": "public",
4774
"registry": "https://registry.npmjs.org/"

0 commit comments

Comments
 (0)