mirror of
https://github.com/mshick/add-pr-comment.git
synced 2026-01-01 14:49:44 +11:00
trigger
This commit is contained in:
parent
b1fd9d1ff1
commit
ad8b9da219
3 changed files with 31 additions and 3 deletions
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
|
|
@ -14,3 +14,4 @@ jobs:
|
||||||
with:
|
with:
|
||||||
msg: Hello!
|
msg: Hello!
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
allow-repeats: false
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ inputs:
|
||||||
repo-token:
|
repo-token:
|
||||||
description: "a github token for API access"
|
description: "a github token for API access"
|
||||||
required: true
|
required: true
|
||||||
|
allow-repeats:
|
||||||
|
description: "allow messages to be repeated"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: "node12"
|
||||||
main: "index.js"
|
main: "index.js"
|
||||||
|
|
|
||||||
29
index.js
29
index.js
|
|
@ -5,23 +5,29 @@ async function run() {
|
||||||
try {
|
try {
|
||||||
const msg = core.getInput("msg");
|
const msg = core.getInput("msg");
|
||||||
const repoToken = core.getInput("repo-token");
|
const repoToken = core.getInput("repo-token");
|
||||||
|
const allowRepeats = core.getInput("allow-repeats");
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`allow repeats: ${allowRepeats}, typeof ${typeof allowRepeats}`
|
||||||
|
);
|
||||||
|
|
||||||
core.debug(`Input message: ${msg}`);
|
core.debug(`Input message: ${msg}`);
|
||||||
|
|
||||||
const octokit = new github.GitHub(repoToken);
|
const octokit = new github.GitHub(repoToken);
|
||||||
const {
|
const {
|
||||||
payload: {
|
payload: {
|
||||||
|
after: commitSha,
|
||||||
pull_request: pullRequestPayload,
|
pull_request: pullRequestPayload,
|
||||||
repository: repositoryPayload
|
repository: repositoryPayload
|
||||||
}
|
}
|
||||||
} = github.context;
|
} = github.context;
|
||||||
|
|
||||||
const { number: pullNumber } = pullRequestPayload;
|
const { number: pullNumber } = pullRequestPayload;
|
||||||
const { owner: repoOwner, full_name: repoFullName } = repositoryPayload;
|
const { full_name: repoFullName } = repositoryPayload;
|
||||||
const [owner, repo] = repoFullName.split("/");
|
const [owner, repo] = repoFullName.split("/");
|
||||||
|
|
||||||
core.debug(`OWNER-------------------------------`);
|
// core.debug(`OWNER-------------------------------`);
|
||||||
console.log(repoOwner);
|
// console.log(repoOwner);
|
||||||
|
|
||||||
const { data: pr } = await octokit.pulls.get({
|
const { data: pr } = await octokit.pulls.get({
|
||||||
owner,
|
owner,
|
||||||
|
|
@ -40,6 +46,23 @@ async function run() {
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(comments);
|
console.log(comments);
|
||||||
|
|
||||||
|
if (allowRepeats === false) {
|
||||||
|
core.debug(`NOT ALLOWING REPEATS, CHECK FOR DUPES`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// duplicate = coms.find { | c | c["user"]["login"] == "github-actions[bot]" && c["body"] == message }
|
||||||
|
// if duplicate
|
||||||
|
// puts "The PR already contains a database change notification"
|
||||||
|
// exit(0)
|
||||||
|
// end
|
||||||
|
|
||||||
|
octokit.issues.createComment({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: pullNumber,
|
||||||
|
body: msg
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue