From 2fe9b691172496703b1cabc92ef6d3627054316f Mon Sep 17 00:00:00 2001 From: Jason Solis Date: Wed, 29 Jun 2022 13:22:33 -0400 Subject: [PATCH] add use-sudo optional parameter defaulting to false. Fixes: #85 Signed-off-by: Jason Solis --- .github/workflows/test-action.yml | 3 ++- README.md | 1 + action.yml | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index b29af6b..d9562e3 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -1,6 +1,6 @@ name: test-cosign -on: [pull_request] +on: [pull_request, workflow_dispatch] jobs: test_cosign_action: @@ -180,6 +180,7 @@ jobs: uses: ./ with: install-dir: /usr/bin + use-sudo: true - name: Check install! run: cosign version - name: Check install dir! diff --git a/README.md b/README.md index 4099359..b31e44d 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ The following optional inputs: | --- | --- | | `cosign-release` | `cosign` version to use instead of the default. | | `install-dir` | directory to place the `cosign` binary into instead of the default (`$HOME/.cosign`). | +| `use-sudo` | set to `true` if `install-dir` location requires sudo privs. | ## Security diff --git a/action.yml b/action.yml index fc57750..3afb4eb 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,10 @@ inputs: description: 'Where to install the cosign binary' required: false default: '$HOME/.cosign' + use-sudo: + description: 'set to true if install-dir location requires sudo privs' + required: false + default: 'false' runs: using: "composite" steps: @@ -172,8 +176,8 @@ runs: esac SUDO= - if command -v sudo >/dev/null; then - SUDO=sudo + if "${{ inputs.use-sudo }}" == "true" && command -v sudo >/dev/null; then + SUDO=sudo fi expected_bootstrap_version_digest=${bootstrap_sha}