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

Alias args to call and make call optional #162

Merged
merged 7 commits into from
Nov 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,32 @@ jobs:
echo "does not match"
exit 1
fi
call:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: "Test call"
id: test-call
uses: ./
with:
module: github.com/shykes/daggerverse/[email protected]
call: hello
- name: "Test call (check)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case is in the version job - just for clarity, either it should be in a different job, or we could rename this job to something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can rename it. I didn't realize the workflow was called version, I just saw test.yml

run: |
target='${{ steps.test-call.outputs.output }}'
if [[ "$target" == "hello, world!" ]]; then
echo "matches"
exit 0
else
echo "does not match"
exit 1
fi
nocall:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: "Only Install"
uses: ./
- name: "Test Install"
run: |
dagger core version
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
- name: Hello
uses: dagger/dagger-for-github@v6
with:
verb: call
module: github.com/shykes/daggerverse/hello
args: hello --greeting Hola --name Jeremy
call: hello --greeting Hola --name Jeremy
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
```

Expand Down Expand Up @@ -43,4 +42,5 @@ By setting the version to `latest`, this action will install the latest version
| `cloud-token` | Dagger Cloud Token | false | '' |
| `module` | Dagger module to call. Local or Git | 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' |
11 changes: 9 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ inputs:
description: "Whether to stop the Dagger Engine after this run"
required: false
default: "true"
call:
description: "Function and arguments for dagger call"
required: false
default: ""
outputs:
output:
description: "Job output"
Expand Down Expand Up @@ -70,22 +74,25 @@ runs:
| BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh

- id: exec
if: inputs.call != '' || inputs.args != ''
shell: bash
env:
INPUT_MODULE: ${{ inputs.module }}
run: |
tmpout=$(mktemp)
ARGS="${{ inputs.args }}"
ARGS="${ARGS:-"${{ inputs.call }}"}"
cd ${{ inputs.workdir }} && { \
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
dagger \
${{ inputs.dagger-flags }} \
${{ inputs.verb }} \
${INPUT_MODULE:+-m $INPUT_MODULE} \
${{ inputs.args }}; } | tee "${tmpout}"
$ARGS; } | tee "${tmpout}"

(echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT"

- if: inputs.engine-stop == 'true'
- if: (inputs.call != '' || inputs.args != '') && inputs.engine-stop == 'true'
shell: bash
run: |
mapfile -t containers < <(docker ps --filter name="dagger-engine-*" -q)
Expand Down