Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add use-sudo optional parameter defaulting to false. Fixes: #85 #84

Merged
merged 1 commit into from Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/test-action.yml
@@ -1,6 +1,10 @@
name: test-cosign

on: [pull_request]
on:
pull_request:
push:
branches:
- 'main'

jobs:
test_cosign_action:
Expand Down Expand Up @@ -180,6 +184,7 @@ jobs:
uses: ./
with:
install-dir: /usr/bin
use-sudo: true
- name: Check install!
run: cosign version
- name: Check install dir!
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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. Defaults to false. |

## Security

Expand Down
14 changes: 9 additions & 5 deletions action.yml
Expand Up @@ -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:
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -211,13 +215,13 @@ runs:
# v0.6.0's linux release has a dependency on `libpcsclite1`
log_info "Installing libpcsclite1 package if necessary..."
set +e
$SUDO dpkg -s libpcsclite1
sudo dpkg -s libpcsclite1
if [ $? -eq 0 ]; then
log_info "libpcsclite1 package is already installed"
else
log_info "libpcsclite1 package is not installed, installing it now."
$SUDO apt-get update -q -q
$SUDO apt-get install -yq libpcsclite1
sudo apt-get update -q -q
sudo apt-get install -yq libpcsclite1
fi
set -e
fi
Expand Down