Skip to content

Commit e606120

Browse files
committed
simplify should-run conditionals
Signed-off-by: kpenfound <kyle@dagger.io>
1 parent bb3e382 commit e606120

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

action.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,19 @@ runs:
108108
BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
109109
echo "::endgroup::"
110110
111+
- id: should-exec
112+
shell: bash
113+
run: |
114+
# Determine if the user wants to execute a dagger command or just install
115+
if [[ -n "${{ inputs.call }}" ]] || \
116+
[[ -n "${{ inputs.shell }}" ]] || \
117+
[[ -n "${{ inputs.args }}" ]] || \
118+
[[ -n "${{ inputs.check }}" ]] || \
119+
[[ "${{ inputs.verb }}" != "call" ]]; then
120+
echo "result=true" >> "$GITHUB_OUTPUT"
121+
fi
111122
- id: assemble
112-
if: inputs.call != '' || inputs.shell != '' || inputs.args != '' || inputs.check != ''
123+
if: steps.should-exec.outputs.result == 'true'
113124
shell: bash
114125
env:
115126
INPUT_MODULE: ${{ inputs.module }}
@@ -119,10 +130,13 @@ runs:
119130
dagger_flags=$(echo '${{ toJSON(inputs.dagger-flags) }}' | jq -rj .)
120131
args=$(echo '${{ toJSON(inputs.args) }}' | jq -rj .)
121132
call=$(echo '${{ toJSON(inputs.call) }}' | jq -rj .)
133+
check=$(echo '${{ toJSON(inputs.check) }}' | jq -rj .)
122134
if [[ -n "${{ inputs.call }}" ]]; then
123135
verb="call"
124-
elif [[ "${{ inputs.check }}" != "" ]]; then
136+
elif [[ -n "$check" ]]; then
125137
verb="check"
138+
# check input is used as a trigger; don't pass glob patterns as args
139+
check=""
126140
elif [[ "$shell" != "" ]]; then
127141
verb=""
128142
script=$(mktemp)
@@ -133,13 +147,14 @@ runs:
133147
echo "dagger-flags=$dagger_flags" >> "$GITHUB_OUTPUT"
134148
echo "args=$args" >> "$GITHUB_OUTPUT"
135149
echo "call=$call" >> "$GITHUB_OUTPUT"
150+
echo "check=$check" >> "$GITHUB_OUTPUT"
136151
- id: exec
137-
if: inputs.call != '' || inputs.shell != '' || inputs.args != '' || inputs.check != ''
152+
if: steps.should-exec.outputs.result == 'true'
138153
shell: bash
139154
env:
140155
INPUT_MODULE: ${{ inputs.module }}
141156
VERB: ${{ steps.assemble.outputs.verb }}
142-
CMD: ${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script || inputs.check }}
157+
CMD: ${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script || steps.assemble.outputs.check }}
143158
SCRIPT: ${{ steps.assemble.outputs.script }}
144159
run: |
145160
tmpout=$(mktemp)

0 commit comments

Comments
 (0)