From 980704f0da998fd2a7ab8aae349d0994f92c781c Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Fri, 5 Jul 2024 13:57:14 -0400 Subject: [PATCH] Skip when dependabot[bot] actor --- dist/index.js | 8 +++++++- src/inputs.ts | 4 ++++ src/main.ts | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1bc8789..88e4ad9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -45385,6 +45385,8 @@ function getInputs() { domain: core.getInput("domain"), setup_only: core.getBooleanInput("setup_only"), pr_comment: core.getBooleanInput("pr_comment"), + github_actor: core.getInput("github_actor"), + github_token: core.getInput("github_token"), // Inputs shared between buf steps. input: core.getInput("input"), paths: core.getMultilineInput("paths"), @@ -45717,9 +45719,13 @@ function parseModuleName(moduleName) { // main is the entrypoint for the action. async function main() { const inputs = getInputs(); - const github = (0,lib_github.getOctokit)(core.getInput("github_token")); + const github = (0,lib_github.getOctokit)(inputs.github_token); const [bufPath, bufVersion] = await installBuf(github, inputs.version); core.setOutput(Outputs.BufVersion, bufVersion); + if (inputs.github_actor == "dependabot[bot]") { + core.info("Skipping steps for dependabot"); + return; + } await login(bufPath, inputs); if (inputs.setup_only) { core.info("Setup only, skipping steps"); diff --git a/src/inputs.ts b/src/inputs.ts index b1ea958..783bfb7 100644 --- a/src/inputs.ts +++ b/src/inputs.ts @@ -28,6 +28,8 @@ export interface Inputs { domain: string; setup_only: boolean; pr_comment: boolean; + github_actor: string; + github_token: string; input: string; paths: string[]; @@ -53,6 +55,8 @@ export function getInputs(): Inputs { domain: core.getInput("domain"), setup_only: core.getBooleanInput("setup_only"), pr_comment: core.getBooleanInput("pr_comment"), + github_actor: core.getInput("github_actor"), + github_token: core.getInput("github_token"), // Inputs shared between buf steps. input: core.getInput("input"), paths: core.getMultilineInput("paths"), diff --git a/src/main.ts b/src/main.ts index ddd77cd..27baae3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,11 +30,14 @@ import { parseModuleNames, ModuleName } from "./config"; // main is the entrypoint for the action. async function main() { const inputs = getInputs(); - const github = getOctokit(core.getInput("github_token")); + const github = getOctokit(inputs.github_token); const [bufPath, bufVersion] = await installBuf(github, inputs.version); core.setOutput(Outputs.BufVersion, bufVersion); + if (inputs.github_actor == "dependabot[bot]") { + core.info("Skipping steps for dependabot"); + return; + } await login(bufPath, inputs); - if (inputs.setup_only) { core.info("Setup only, skipping steps"); return;