Skip to content

Commit fd68feb

Browse files
committed
fail instead of label
1 parent c92b377 commit fd68feb

File tree

40 files changed

+272
-874
lines changed

40 files changed

+272
-874
lines changed

index.js

+1-49
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,21 @@
11
const core = require("@actions/core");
22
const github = require("@actions/github");
3-
const { Octokit } = require("@octokit/action");
43

5-
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
6-
const issueNumber = process.env.GITHUB_REF.split("/")[2];
74
const jiraPrefix = core.getInput("jira-prefix");
8-
const octokit = new Octokit();
95

106
async function run() {
117
try {
12-
const labelName = "Missing Jira issue key";
13-
const labelColor = "EEEEEE";
148
const prTitle = github.context.payload.pull_request.title;
159
const prBody = github.context.payload.pull_request.body;
1610

17-
try {
18-
let createResponse = await octokit.issues.createLabel({
19-
owner,
20-
repo,
21-
name: labelName,
22-
color: labelColor,
23-
});
24-
core.info(`Creating label (${labelName}) - ` + createResponse.status);
25-
} catch (error) {
26-
core.info(`Label (${labelName}) exists.`);
27-
}
28-
2911
let regex = new RegExp(`${jiraPrefix}}-[0-9]+`);
3012
if (!regex.test(prTitle) || !regex.test(prBody)) {
31-
addLabel(labelName);
13+
core.setFailed("Jira Issue Key missing in PR title or description.");
3214
return;
3315
}
34-
35-
removeLabel(labelName);
3616
} catch (error) {
3717
core.info(error);
3818
}
3919
}
4020

41-
async function addLabel(name) {
42-
try {
43-
let addLabelResponse = await octokit.issues.addLabels({
44-
owner,
45-
repo,
46-
issueNumber,
47-
labels: [name],
48-
});
49-
core.info(`Adding label (${name}) - ` + addLabelResponse.status);
50-
} catch (error) {
51-
core.info("Label already added.");
52-
}
53-
}
54-
55-
async function removeLabel(name) {
56-
try {
57-
let removeLabelResponse = await octokit.issues.removeLabel({
58-
owner,
59-
repo,
60-
issueNumber,
61-
name: name,
62-
});
63-
core.info("Check passed. Deleting label - " + removeLabelResponse.status);
64-
} catch (error) {
65-
core.info("Label already removed.");
66-
}
67-
}
68-
6921
run();

node_modules/@actions/core/package.json

+12-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/github/package.json

+12-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/package.json

+13-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@octokit/action/LICENSE

-21
This file was deleted.

node_modules/@octokit/action/README.md

-130
This file was deleted.

node_modules/@octokit/action/dist-node/index.js

-18
This file was deleted.

node_modules/@octokit/action/dist-node/index.js.map

-1
This file was deleted.

0 commit comments

Comments
 (0)