Skip to content

Commit

Permalink
Skip when dependabot[bot] actor (#44)
Browse files Browse the repository at this point in the history
Dependabot doesn't have access to repository secrets failing to run
workflows when automatically run. We can easily check in the action for
the actor
[`dependabot[bot]`](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events)
to skip these cases. This avoids users having to configure the action
themselves.
  • Loading branch information
emcfarlane authored Jul 15, 2024
1 parent 0a9ac0c commit 9c103e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45396,6 +45396,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"),
Expand Down Expand Up @@ -45735,9 +45737,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");
Expand Down
4 changes: 4 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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"),
Expand Down
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ 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");
Expand Down

0 comments on commit 9c103e4

Please sign in to comment.