From bf099f5b86bb1c7c84c64888c8cca39c68c606d5 Mon Sep 17 00:00:00 2001 From: Andre Wiggins Date: Tue, 28 Jul 2020 15:41:10 -0700 Subject: [PATCH] Only run action on pull_request event (Fixes #8) --- dist/main.js | 8 ++++++++ dist/pre.js | 6 ++++++ src/actions/main.js | 8 ++++++++ src/actions/pre.js | 6 ++++++ 4 files changed, 28 insertions(+) diff --git a/dist/main.js b/dist/main.js index 9cb448d..f6b8004 100644 --- a/dist/main.js +++ b/dist/main.js @@ -51,6 +51,14 @@ async function createCheck(github, context) { const inputs = getInputs(logger); const octokit = util.github.getOctokit(token); + if (util.github.context.eventName !== "pull_request") { + logger.info( + "Not a pull request event. Skipping this action and doing nothing." + ); + logger.info("Event name: " + util.github.context.eventName); + return; + } + let finish; if (useCheck == "true") { finish = await createCheck(octokit, util.github.context); diff --git a/dist/pre.js b/dist/pre.js index 7997af1..d4f4541 100644 --- a/dist/pre.js +++ b/dist/pre.js @@ -37,6 +37,12 @@ const { getLogger, getInputs } = util.util; 'No reportId provided. Skipping updating comment with "Running..." status.' ); + return; + } else if (context.eventName !== "pull_request") { + logger.info( + "Not a pull request event. Skipping this action and doing nothing." + ); + logger.info("Event name: " + util.github.context.eventName); return; } diff --git a/src/actions/main.js b/src/actions/main.js index 676bdf8..b8a01af 100644 --- a/src/actions/main.js +++ b/src/actions/main.js @@ -35,6 +35,14 @@ async function createCheck(github, context) { const inputs = getInputs(logger); const octokit = github.getOctokit(token); + if (github.context.eventName !== "pull_request") { + logger.info( + "Not a pull request event. Skipping this action and doing nothing." + ); + logger.info("Event name: " + github.context.eventName); + return; + } + let finish; if (useCheck == "true") { finish = await createCheck(octokit, github.context); diff --git a/src/actions/pre.js b/src/actions/pre.js index 7783bb2..aafcfba 100644 --- a/src/actions/pre.js +++ b/src/actions/pre.js @@ -21,6 +21,12 @@ const { getLogger, getInputs } = require("./util"); 'No reportId provided. Skipping updating comment with "Running..." status.' ); + return; + } else if (context.eventName !== "pull_request") { + logger.info( + "Not a pull request event. Skipping this action and doing nothing." + ); + logger.info("Event name: " + github.context.eventName); return; }