From 1d9f40bf63b9f8c898d696c7e269521bebbb2b54 Mon Sep 17 00:00:00 2001 From: crazy-matt <46377983+crazy-matt@users.noreply.github.com> Date: Tue, 12 Jan 2021 12:05:53 +0000 Subject: [PATCH] Fix https://github.com/zricethezav/gitleaks-action/issues/11 ...updating entrypoint.sh and action.yml to enable a GitHub Action input variable config-path allowing to set the .gitleaks.toml file path --- README.md | 17 ++++++++++++++++- action.yml | 7 +++++++ entrypoint.sh | 9 ++++++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d5a7fc3..8b78c2e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,22 @@ jobs: ``` ### Using your own .gitleaks.toml configuration -Include a .gitleaks.toml in the root of your repo directory. +``` +name: gitleaks + +on: [push,pull_request] + +jobs: + gitleaks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: gitleaks-action + uses: zricethezav/gitleaks-action@master + with: + config-path: security/.gitleaks.toml +``` + > The `config-path` is relative to your GitHub Worskpace ### NOTE!!! You must use `actions/checkout` before the gitleaks-action step. If you are using `actions/checkout@v2` you must specify a commit depth other than the default which is 1. diff --git a/action.yml b/action.yml index fd758d5..cecabda 100644 --- a/action.yml +++ b/action.yml @@ -3,6 +3,11 @@ description: Run Gitleaks on Push and PR events branding: color: purple icon: eye +inputs: + config-path: + description: 'Path to config (relative to $GITHUB_WORKSPACE)' + required: false + default: '.github/.gitleaks.toml' outputs: result: # id of output description: 'Gitleaks log output' @@ -11,3 +16,5 @@ outputs: runs: using: "docker" image: "Dockerfile" + args: + - ${{ inputs.config-path }} diff --git a/entrypoint.sh b/entrypoint.sh index de13caf..475e382 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,12 @@ #!/bin/bash +INPUT_CONFIG_PATH="$1" CONFIG="" -# check if using gitleaks config or not -if [ -f "$GITHUB_WORKSPACE/.gitleaks.toml" ] -then + +# check if a custom config have been provided +if [ -f "$GITHUB_WORKSPACE/$INPUT_CONFIG_PATH" ]; then + CONFIG=" --config-path=$GITHUB_WORKSPACE/$INPUT_CONFIG_PATH" +else CONFIG=" --config-path=$GITHUB_WORKSPACE/.gitleaks.toml" fi