mirror of
https://github.com/dagger/dagger-for-github.git
synced 2026-01-01 13:10:18 +11:00
alias call to args and make it optional
Signed-off-by: kpenfound <kyle@dagger.io>
This commit is contained in:
parent
a320953b08
commit
367e5106ee
3 changed files with 26 additions and 4 deletions
16
.github/workflows/test.yml
vendored
16
.github/workflows/test.yml
vendored
|
|
@ -93,3 +93,19 @@ jobs:
|
||||||
echo "does not match"
|
echo "does not match"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
- name: "Test call"
|
||||||
|
id: test-call
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
module: github.com/shykes/daggerverse/hello@v0.3.0
|
||||||
|
call: hello
|
||||||
|
- name: "Test call (check)"
|
||||||
|
run: |
|
||||||
|
target='${{ steps.test-call.outputs.output }}'
|
||||||
|
if [[ "$target" == "hello, world!" ]]; then
|
||||||
|
echo "matches"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "does not match"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@
|
||||||
- name: Hello
|
- name: Hello
|
||||||
uses: dagger/dagger-for-github@v6
|
uses: dagger/dagger-for-github@v6
|
||||||
with:
|
with:
|
||||||
verb: call
|
|
||||||
module: github.com/shykes/daggerverse/hello
|
module: github.com/shykes/daggerverse/hello
|
||||||
args: hello --greeting Hola --name Jeremy
|
call: hello --greeting Hola --name Jeremy
|
||||||
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
|
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -43,4 +42,5 @@ By setting the version to `latest`, this action will install the latest version
|
||||||
| `cloud-token` | Dagger Cloud Token | false | '' |
|
| `cloud-token` | Dagger Cloud Token | false | '' |
|
||||||
| `module` | Dagger module to call. Local or Git | false | '' |
|
| `module` | Dagger module to call. Local or Git | false | '' |
|
||||||
| `args` | Arguments to pass to CLI | false | '' |
|
| `args` | Arguments to pass to CLI | false | '' |
|
||||||
|
| `call` | Arguments to pass to CLI (Alias for args) | false | '' |
|
||||||
| `engine-stop` | Whether to stop the Dagger Engine after this run | false | 'true' |
|
| `engine-stop` | Whether to stop the Dagger Engine after this run | false | 'true' |
|
||||||
|
|
|
||||||
10
action.yml
10
action.yml
|
|
@ -37,6 +37,10 @@ inputs:
|
||||||
description: "Whether to stop the Dagger Engine after this run"
|
description: "Whether to stop the Dagger Engine after this run"
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
|
call:
|
||||||
|
description: "Function and arguments for dagger call"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
outputs:
|
outputs:
|
||||||
output:
|
output:
|
||||||
description: "Job output"
|
description: "Job output"
|
||||||
|
|
@ -70,22 +74,24 @@ runs:
|
||||||
| BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
|
| BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
|
||||||
|
|
||||||
- id: exec
|
- id: exec
|
||||||
|
if: inputs.call != '' || inputs.args != ''
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
INPUT_MODULE: ${{ inputs.module }}
|
INPUT_MODULE: ${{ inputs.module }}
|
||||||
run: |
|
run: |
|
||||||
tmpout=$(mktemp)
|
tmpout=$(mktemp)
|
||||||
|
INPUT_ARGS="${ INPUT_ARGS:-INPUT_CALL }"
|
||||||
cd ${{ inputs.workdir }} && { \
|
cd ${{ inputs.workdir }} && { \
|
||||||
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
|
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
|
||||||
dagger \
|
dagger \
|
||||||
${{ inputs.dagger-flags }} \
|
${{ inputs.dagger-flags }} \
|
||||||
${{ inputs.verb }} \
|
${{ inputs.verb }} \
|
||||||
${INPUT_MODULE:+-m $INPUT_MODULE} \
|
${INPUT_MODULE:+-m $INPUT_MODULE} \
|
||||||
${{ inputs.args }}; } | tee "${tmpout}"
|
$INPUT_ARGS; } | tee "${tmpout}"
|
||||||
|
|
||||||
(echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT"
|
(echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- if: inputs.engine-stop == 'true'
|
- if: (inputs.call != '' || inputs.args != '') && inputs.engine-stop == 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
mapfile -t containers < <(docker ps --filter name="dagger-engine-*" -q)
|
mapfile -t containers < <(docker ps --filter name="dagger-engine-*" -q)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue