Skip to content

Commit

Permalink
Add explicit sudo option to action.yml (#29)
Browse files Browse the repository at this point in the history
## PRs in the Stack
- ➡ #29

(The stack is managed by
[git-grok](https://github.com/dimikot/git-grok).)
  • Loading branch information
dimikot authored Oct 7, 2024
1 parent dd5ebbc commit 91b541d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
with:
action: store
storage-dir: ~/storage-dir
sudo: false
- name: Test store (layer)
uses: ./
with:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ ones, so rsync can run efficiently.
# Default: empty.
layer-include: ''

# If set, uses /usr/bin/ci-storage path and runs it with sudo. Useful for
# storing/loading privileged directories like Docker volumes.
# Default: false.
sudo: ''

# If set, prints the list of transferred files.
# Default: false.
verbose: ''
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ inputs:
layer-include:
description: "Newline-separated include pattern(s) for rsync. If set, only the files matching the patterns will be transferred. Implies setting layer-name. Default: empty."
required: false
sudo:
description: "If set, uses /usr/bin/ci-storage path and runs it with sudo. Useful for storing/loading privileged directories like Docker volumes. Default: false."
required: false
verbose:
description: "If set, prints the list of transferred files. Default: false."
required: false
Expand All @@ -56,6 +59,7 @@ runs:
exclude="${{ inputs.exclude || '' }}"
layer_name="${{ inputs.layer-name || '' }}"
layer_include="${{ inputs.layer-include || '' }}"
sudo="${{ inputs.sudo || '' }}"
verbose="${{ inputs.verbose && '--verbose' || '' }}"
if [[ "$storage_host" == "" ]]; then
Expand Down Expand Up @@ -97,7 +101,7 @@ runs:
"$action"
)
if [[ -d "$local_dir" && "$(stat -c '%U' "$local_dir")" != "$whoami" ]]; then
if [[ "$sudo" == yes || "$sudo" == true || "$sudo" == on || "$sudo" == 1 ]]; then
sudo /usr/bin/ci-storage "${args[@]}"
else
"${{ github.action_path }}/ci-storage" "${args[@]}"
Expand Down

0 comments on commit 91b541d

Please sign in to comment.