From 2af9604f13f36547728e70c7779f30b5ad5f6914 Mon Sep 17 00:00:00 2001 From: James Ives Date: Mon, 27 Jan 2020 23:55:28 -0500 Subject: [PATCH] Adds git config options. (#154) * Adds git config options. * Compile --- .github/workflows/integration-beta.yml | 2 ++ .github/workflows/integration.yml | 4 ++++ README.md | 2 ++ action.yml | 8 ++++++++ lib/constants.js | 23 ++++++++++++++--------- src/constants.ts | 25 ++++++++++++++----------- tslint.json | 2 +- 7 files changed, 45 insertions(+), 21 deletions(-) diff --git a/.github/workflows/integration-beta.yml b/.github/workflows/integration-beta.yml index 2a964759..c571e46a 100644 --- a/.github/workflows/integration-beta.yml +++ b/.github/workflows/integration-beta.yml @@ -24,6 +24,8 @@ jobs: FOLDER: integration BASE_BRANCH: dev TARGET_FOLDER: montezuma + GIT_CONFIG_NAME: Montezuma + GIT_CONFIG_EMAIL: montezuma@jamesiv.es # Deploys using checkout@v2 with a GITHUB_TOKEN. integration-checkout-v2: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 36aa9d2a..361728ce 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -23,6 +23,8 @@ jobs: FOLDER: integration BASE_BRANCH: dev TARGET_FOLDER: montezuma + GIT_CONFIG_NAME: Montezuma + GIT_CONFIG_EMAIL: montezuma@jamesiv.es # Deploys using checkout@v2 with a GITHUB_TOKEN. integration-checkout-v2: @@ -31,6 +33,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + with: + persist-credentials: false - name: Build and Deploy uses: JamesIves/github-pages-deploy-action@releases/v3 diff --git a/README.md b/README.md index 5abdea00..7e4a3ba9 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ In addition to the deployment options you must also configure the following. | Key | Value Information | Type | Required | | ------------- | ------------- | ------------- | ------------- | +| `GIT_CONFIG_NAME` | Allows you to customize the name that is attached to the GitHub config which is used when pushing the deployment commits. If this is not included it will use the name in the GitHub context, followed by the name of the action. | `with` | **No** | +| `GIT_CONFIG_EMAIL` | Allows you to customize the email that is attached to the GitHub config which is used when pushing the deployment commits. If this is not included it will use the email in the GitHub context, followed by a generic noreply GitHub email. | `with` | **No** | | `TARGET_FOLDER` | If you'd like to push the contents of the deployment folder into a specific directory on the deployment branch you can specify it here. | `with` | **No** | | `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to the current commit [SHA](http://en.wikipedia.org/wiki/SHA-1) that triggered the build followed by `master` if it doesn't exist. This is useful for making deployments from another branch, and also may be necessary when using a scheduled job. | `with` | **No** | | `COMMIT_MESSAGE` | If you need to customize the commit message for an integration you can do so. | `with` | **No** | diff --git a/action.yml b/action.yml index cf1f2f35..9c080268 100644 --- a/action.yml +++ b/action.yml @@ -47,3 +47,11 @@ inputs: CLEAN_EXCLUDE: description: "If you need to use CLEAN but you would like to preserve certain files or folders you can use this option. This should be formatted as an array but stored as a string." required: false + + GIT_CONFIG_NAME: + description: "Allows you to customize the name that is attached to the GitHub config which is used when pushing the deployment commits. If this is not included it will use the name in the GitHub context, followed by the name of the action." + required: false + + GIT_CONFIG_EMAIL: + description: "Allows you to customize the email that is attached to the GitHub config which is used when pushing the deployment commits. If this is not included it will use the email in the GitHub context, followed by a generic noreply GitHub email." + required: false \ No newline at end of file diff --git a/lib/constants.js b/lib/constants.js index c8106a78..f37b74fa 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -9,6 +9,7 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@actions/core"); const github = __importStar(require("@actions/github")); +const util_1 = require("./util"); const { pusher, repository } = github.context.payload; exports.workspace = process.env.GITHUB_WORKSPACE; exports.folder = core_1.getInput("FOLDER", { required: true }); @@ -25,19 +26,23 @@ exports.action = { defaultBranch: process.env.GITHUB_SHA ? process.env.GITHUB_SHA : "master", isTest: process.env.UNIT_TEST, ssh: core_1.getInput("SSH"), - email: pusher && pusher.email - ? pusher.email - : `${process.env.GITHUB_ACTOR || - "github-pages-deploy-action"}@users.noreply.github.com`, + email: !util_1.isNullOrUndefined(core_1.getInput("GIT_CONFIG_EMAIL")) + ? core_1.getInput("GIT_CONFIG_EMAIL") + : pusher && pusher.email + ? pusher.email + : `${process.env.GITHUB_ACTOR || + "github-pages-deploy-action"}@users.noreply.github.com`, gitHubRepository: repository && repository.full_name ? repository.full_name : process.env.GITHUB_REPOSITORY, gitHubToken: core_1.getInput("GITHUB_TOKEN"), - name: pusher && pusher.name - ? pusher.name - : process.env.GITHUB_ACTOR - ? process.env.GITHUB_ACTOR - : "GitHub Pages Deploy Action", + name: !util_1.isNullOrUndefined(core_1.getInput("GIT_CONFIG_NAME")) + ? core_1.getInput("GIT_CONFIG_NAME") + : pusher && pusher.name + ? pusher.name + : process.env.GITHUB_ACTOR + ? process.env.GITHUB_ACTOR + : "GitHub Pages Deploy Action", targetFolder: core_1.getInput("TARGET_FOLDER") }; // Token Types diff --git a/src/constants.ts b/src/constants.ts index cb4af14c..211fecbc 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,6 @@ import { getInput } from "@actions/core"; import * as github from "@actions/github"; +import { isNullOrUndefined } from "./util"; const { pusher, repository } = github.context.payload; @@ -19,22 +20,24 @@ export const action = { defaultBranch: process.env.GITHUB_SHA ? process.env.GITHUB_SHA : "master", isTest: process.env.UNIT_TEST, ssh: getInput("SSH"), - email: - pusher && pusher.email - ? pusher.email - : `${process.env.GITHUB_ACTOR || - "github-pages-deploy-action"}@users.noreply.github.com`, + email: !isNullOrUndefined(getInput("GIT_CONFIG_EMAIL")) + ? getInput("GIT_CONFIG_EMAIL") + : pusher && pusher.email + ? pusher.email + : `${process.env.GITHUB_ACTOR || + "github-pages-deploy-action"}@users.noreply.github.com`, gitHubRepository: repository && repository.full_name ? repository.full_name : process.env.GITHUB_REPOSITORY, gitHubToken: getInput("GITHUB_TOKEN"), - name: - pusher && pusher.name - ? pusher.name - : process.env.GITHUB_ACTOR - ? process.env.GITHUB_ACTOR - : "GitHub Pages Deploy Action", + name: !isNullOrUndefined(getInput("GIT_CONFIG_NAME")) + ? getInput("GIT_CONFIG_NAME") + : pusher && pusher.name + ? pusher.name + : process.env.GITHUB_ACTOR + ? process.env.GITHUB_ACTOR + : "GitHub Pages Deploy Action", targetFolder: getInput("TARGET_FOLDER") }; diff --git a/tslint.json b/tslint.json index 0363ca3b..44382487 100644 --- a/tslint.json +++ b/tslint.json @@ -18,7 +18,7 @@ "no-implicit-dependencies": true, "no-invalid-this": true, "no-string-throw": true, - "no-unsafe-finally": true, + "no-unsafe-finally": false, "no-use-before-declare": true, "no-void-expression": [true, "ignore-arrow-function-shorthand"], "no-duplicate-imports": true,