From 1f4acfa1c0543ed2a8bbd308aa622fd58e2da896 Mon Sep 17 00:00:00 2001 From: Oliver Sand Date: Tue, 7 Jan 2020 10:21:37 +0100 Subject: [PATCH] Make it possible to pass a GitHub token to the action to clone private repositories --- README.md | 13 +++++++++++++ action.yml | 6 +++++- entrypoint.sh | 10 ++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 74d758b..cde924a 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,19 @@ steps: *if custom options argument string is used, it will overwrite default settings +### Private GitHub Repository + +Pass a GitHub access token to action to clone from a private GitHub repository. You can't use the default `GITHUB_TOKEN` as it doesn't have the permission to clone the repository. You have to create an access token manually. + +```yaml +steps: +- uses: actions/checkout@master +- name: trufflehog-actions-scan + uses: edplato/trufflehog-actions-scan@master + with: + githubToken: ${{ secrets.GITHUB_CLONE_TOKEN }} +``` + ---- [MIT License](LICENSE) diff --git a/action.yml b/action.yml index 6b58489..4a1e496 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,10 @@ author: 'Ed Plato' runs: using: 'docker' image: 'Dockerfile' +inputs: + githubToken: + description: 'GitHub Token to access a privat repository' + required: false branding: icon: 'shield' - color: 'yellow' \ No newline at end of file + color: 'yellow' diff --git a/entrypoint.sh b/entrypoint.sh index 5a852d8..ccbbc0b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,5 +7,11 @@ if [ -n "$1" ]; then args="$@" # Overwrite if new options string is provided fi -githubRepo="https://github.com/$GITHUB_REPOSITORY" -trufflehog $args $githubRepo \ No newline at end of file + +if [ -n "${INPUT_GITHUBTOKEN}" ]; then + githubRepo="https://$INPUT_GITHUBTOKEN@github.com/$GITHUB_REPOSITORY" +else + githubRepo="https://github.com/$GITHUB_REPOSITORY" +fi + +trufflehog $args $githubRepo