Skip to content

Commit

Permalink
chore: release version v2.0.0 🥇
Browse files Browse the repository at this point in the history
  • Loading branch information
aaimio committed Jan 18, 2023
1 parent 9f367f7 commit ead2d57
Show file tree
Hide file tree
Showing 2 changed files with 13,895 additions and 12 deletions.
13,887 changes: 13,885 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import core from "@actions/core";
import github from "@actions/github";
import { getInput, setOutput } from "@actions/core";
import { context } from "@actions/github";
import { Octokit } from "@octokit/action";
import { getPreviewUrlFromString } from "./index.utils";

const cancelAction = async () => {
if (core.getInput("GITHUB_TOKEN")) {
if (getInput("GITHUB_TOKEN")) {
const octokit = new Octokit();

await octokit.actions.cancelWorkflowRun({
...github.context.repo,
run_id: github.context.runId,
...context.repo,
run_id: context.runId,
});

// Wait a maximum of 1 minute for the action to be cancelled.
Expand All @@ -21,15 +21,15 @@ const cancelAction = async () => {
};

const runAction = async () => {
const { comment } = github.context.payload;
const { comment } = context.payload;

if (!comment) {
console.log("Action triggered on non-comment event.");
await cancelAction();
return;
}

const vercelBotName = core.getInput("vercel_bot_name");
const vercelBotName = getInput("vercel_bot_name");
const { login } = comment.user;

if (login !== vercelBotName) {
Expand All @@ -40,7 +40,7 @@ const runAction = async () => {
await cancelAction();
}

const cancelOnStrings = core.getInput("cancel_on_strings").split(",");
const cancelOnStrings = getInput("cancel_on_strings").split(",");
const { body } = comment;

if (cancelOnStrings.some((word) => body.includes(word))) {
Expand All @@ -54,7 +54,7 @@ const runAction = async () => {

const vercelPreviewUrl = getPreviewUrlFromString(
body,
core.getInput("preview_url_regexp")
getInput("preview_url_regexp")
);

if (!vercelPreviewUrl) {
Expand All @@ -67,7 +67,7 @@ const runAction = async () => {
}

console.log("Found preview URL.", { vercelPreviewUrl });
core.setOutput("vercel_preview_url", vercelPreviewUrl);
setOutput("vercel_preview_url", vercelPreviewUrl);
process.exit(0);
};

Expand Down

0 comments on commit ead2d57

Please sign in to comment.