From c4cfbc80af945d2f04eb79eab00a41a493c30ecb Mon Sep 17 00:00:00 2001 From: James Ives Date: Fri, 22 Nov 2019 10:01:06 -0500 Subject: [PATCH] Pusher is undefined in scheduled jobs (#62) * Fallback for name and email * Build --- lib/constants.js | 12 ++++++++++-- lib/git.js | 4 ++-- src/constants.ts | 14 ++++++++++++-- src/git.ts | 4 ++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 7f56fb64..a08e2b12 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -24,8 +24,16 @@ exports.action = { accessToken: core.getInput("ACCESS_TOKEN"), branch: core.getInput("BRANCH"), baseBranch: core.getInput("BASE_BRANCH") || "master", - clean: core.getInput("CLEAN"), - pusher + name: pusher && pusher.name + ? pusher.name + : process.env.GITHUB_ACTOR + ? process.env.GITHUB_ACTOR + : "GitHub Pages Deploy Action", + email: pusher && pusher.email + ? pusher.email + : `${process.env.GITHUB_ACTOR || + "github-pages-deploy-action"}@users.noreply.github.com`, + clean: core.getInput("CLEAN") }; // Repository path used for commits/pushes. exports.repositoryPath = `https://${exports.action.accessToken || diff --git a/lib/git.js b/lib/git.js index 984c7c13..81fbe162 100644 --- a/lib/git.js +++ b/lib/git.js @@ -32,8 +32,8 @@ function init() { return core.setFailed(`The deployment folder cannot be prefixed with '/' or './'. Instead reference the folder name directly.`); } yield util_1.execute(`git init`, constants_1.workspace); - yield util_1.execute(`git config user.name ${constants_1.action.pusher.name}`, constants_1.workspace); - yield util_1.execute(`git config user.email ${constants_1.action.pusher.email}`, constants_1.workspace); + yield util_1.execute(`git config user.name ${constants_1.action.name}`, constants_1.workspace); + yield util_1.execute(`git config user.email ${constants_1.action.email}`, constants_1.workspace); } catch (error) { core.setFailed(`There was an error initializing the repository: ${error}`); diff --git a/src/constants.ts b/src/constants.ts index 9d10dc12..1d448f06 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -19,8 +19,18 @@ export const action = { accessToken: core.getInput("ACCESS_TOKEN"), branch: core.getInput("BRANCH"), baseBranch: core.getInput("BASE_BRANCH") || "master", - clean: core.getInput("CLEAN"), - pusher + name: + pusher && pusher.name + ? pusher.name + : process.env.GITHUB_ACTOR + ? process.env.GITHUB_ACTOR + : "GitHub Pages Deploy Action", + email: + pusher && pusher.email + ? pusher.email + : `${process.env.GITHUB_ACTOR || + "github-pages-deploy-action"}@users.noreply.github.com`, + clean: core.getInput("CLEAN") }; // Repository path used for commits/pushes. diff --git a/src/git.ts b/src/git.ts index f3fa36dc..62aaa867 100644 --- a/src/git.ts +++ b/src/git.ts @@ -20,8 +20,8 @@ export async function init(): Promise { } await execute(`git init`, workspace); - await execute(`git config user.name ${action.pusher.name}`, workspace); - await execute(`git config user.email ${action.pusher.email}`, workspace); + await execute(`git config user.name ${action.name}`, workspace); + await execute(`git config user.email ${action.email}`, workspace); } catch (error) { core.setFailed(`There was an error initializing the repository: ${error}`); } finally {