Skip to content

Commit e3a863e

Browse files
authored
Merge pull request #162 from kpenfound/optional_call
Alias args to call and make call optional
2 parents a320953 + b61bdaa commit e3a863e

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,32 @@ jobs:
9393
echo "does not match"
9494
exit 1
9595
fi
96+
call:
97+
runs-on: "ubuntu-latest"
98+
steps:
99+
- uses: actions/checkout@v4
100+
- name: "Test call"
101+
id: test-call
102+
uses: ./
103+
with:
104+
module: github.com/shykes/daggerverse/[email protected]
105+
call: hello
106+
- name: "Test call (check)"
107+
run: |
108+
target='${{ steps.test-call.outputs.output }}'
109+
if [[ "$target" == "hello, world!" ]]; then
110+
echo "matches"
111+
exit 0
112+
else
113+
echo "does not match"
114+
exit 1
115+
fi
116+
nocall:
117+
runs-on: "ubuntu-latest"
118+
steps:
119+
- uses: actions/checkout@v4
120+
- name: "Only Install"
121+
uses: ./
122+
- name: "Test Install"
123+
run: |
124+
dagger core version

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
- name: Hello
99
uses: dagger/dagger-for-github@v6
1010
with:
11-
verb: call
1211
module: github.com/shykes/daggerverse/hello
13-
args: hello --greeting Hola --name Jeremy
12+
call: hello --greeting Hola --name Jeremy
1413
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
1514
```
1615
@@ -43,4 +42,5 @@ By setting the version to `latest`, this action will install the latest version
4342
| `cloud-token` | Dagger Cloud Token | false | '' |
4443
| `module` | Dagger module to call. Local or Git | false | '' |
4544
| `args` | Arguments to pass to CLI | false | '' |
45+
| `call` | Arguments to pass to CLI (Alias for args) | false | '' |
4646
| `engine-stop` | Whether to stop the Dagger Engine after this run | false | 'true' |

action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ inputs:
3737
description: "Whether to stop the Dagger Engine after this run"
3838
required: false
3939
default: "true"
40+
call:
41+
description: "Function and arguments for dagger call"
42+
required: false
43+
default: ""
4044
outputs:
4145
output:
4246
description: "Job output"
@@ -70,22 +74,25 @@ runs:
7074
| BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
7175
7276
- id: exec
77+
if: inputs.call != '' || inputs.args != ''
7378
shell: bash
7479
env:
7580
INPUT_MODULE: ${{ inputs.module }}
7681
run: |
7782
tmpout=$(mktemp)
83+
ARGS="${{ inputs.args }}"
84+
ARGS="${ARGS:-"${{ inputs.call }}"}"
7885
cd ${{ inputs.workdir }} && { \
7986
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
8087
dagger \
8188
${{ inputs.dagger-flags }} \
8289
${{ inputs.verb }} \
8390
${INPUT_MODULE:+-m $INPUT_MODULE} \
84-
${{ inputs.args }}; } | tee "${tmpout}"
91+
$ARGS; } | tee "${tmpout}"
8592
8693
(echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT"
8794
88-
- if: inputs.engine-stop == 'true'
95+
- if: (inputs.call != '' || inputs.args != '') && inputs.engine-stop == 'true'
8996
shell: bash
9097
run: |
9198
mapfile -t containers < <(docker ps --filter name="dagger-engine-*" -q)

0 commit comments

Comments
 (0)