Skip to content
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
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,27 @@ jobs:
exit 1
fi

check:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
repository: "kpenfound/dag"
ref: "3ea64a3711c2d785db3133dd380ae74ac1440f79"
path: "./dag"
- name: "Test check"
uses: ./
with:
check: "**"
workdir: "./dag/hello"
enable-github-summary: true
- name: "Test check"
uses: ./
with:
verb: "check"
workdir: "./dag/hello"

shell:
runs-on: "ubuntu-latest"
steps:
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

## Usage Examples

### `dagger check`

```yaml
- name: Hello
uses: dagger/dagger-for-github@v8.3.0
with:
check: "**"
version: "latest" # semver vX.Y.Z
```

Note: As a convenience for `dagger check` you can use the [dagger/checks](https://github.com/dagger/checks) action instead.

### `dagger call`

```yaml
- name: Hello
uses: dagger/dagger-for-github@v8.2.0
uses: dagger/dagger-for-github@v8.3.0
with:
module: github.com/shykes/daggerverse/hello
call: hello --greeting Hola --name Jeremy
Expand All @@ -18,7 +30,7 @@

```yaml
- name: Hello
uses: dagger/dagger-for-github@v8.2.0
uses: dagger/dagger-for-github@v8.3.0
with:
shell: container | from alpine | with-exec echo,"hello, world!" | stdout
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
Expand All @@ -28,7 +40,7 @@

```yaml
- name: Integration Test
uses: dagger/dagger-for-github@v8.2.0
uses: dagger/dagger-for-github@v8.3.0
with:
workdir: db-service
verb: run
Expand All @@ -55,6 +67,7 @@ By setting the version to `latest`, this action will install the latest version
| `args` | Arguments to pass to CLI | false | '' |
| `call` | Arguments to pass to CLI (Alias for args with verb:call) | false | '' |
| `shell` | Arguments to pass to CLI (Alias for args with verb:shell) | false | '' |
| `check` | Arguments to pass to CLI (Alias for args with verb:check) | false | '' |
| `summary-path` | File path to write the job summary to | false | '' |
| `enable-github-summary` | Whether to automatically write a GitHub Actions job summary | false | 'false' |

Expand Down
40 changes: 33 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
required: false
default: "--progress plain"
verb:
description: "CLI verb (call, run, download, up, functions, shell, query)"
description: "CLI verb (check, call, run, download, up, functions, shell, query)"
required: false
default: "call"
workdir:
Expand Down Expand Up @@ -45,6 +45,10 @@ inputs:
description: "Function and arguments for dagger shell"
required: false
default: ""
check:
description: "Function and arguments for dagger check"
required: false
default: ""
summary-path:
description: "File path to write the job summary"
required: false
Expand Down Expand Up @@ -104,8 +108,25 @@ runs:
BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
echo "::endgroup::"

- id: should-exec
shell: bash
env:
INPUT_CALL: ${{ inputs.call }}
INPUT_SHELL: ${{ inputs.shell }}
INPUT_ARGS: ${{ inputs.args }}
INPUT_CHECK: ${{ inputs.check }}
INPUT_VERB: ${{ inputs.verb }}
run: |
# Determine if the user wants to execute a dagger command or just install
if [[ -n "$INPUT_CALL" ]] || \
[[ -n "$INPUT_SHELL" ]] || \
[[ -n "$INPUT_ARGS" ]] || \
[[ -n "$INPUT_CHECK" ]] || \
[[ "$INPUT_VERB" != "call" ]]; then
echo "result=true" >> "$GITHUB_OUTPUT"
fi
- id: assemble
if: inputs.call != '' || inputs.shell != '' || inputs.args != ''
if: steps.should-exec.outputs.result == 'true'
shell: bash
env:
INPUT_MODULE: ${{ inputs.module }}
Expand All @@ -115,8 +136,13 @@ runs:
dagger_flags=$(echo '${{ toJSON(inputs.dagger-flags) }}' | jq -rj .)
args=$(echo '${{ toJSON(inputs.args) }}' | jq -rj .)
call=$(echo '${{ toJSON(inputs.call) }}' | jq -rj .)
check=$(echo '${{ toJSON(inputs.check) }}' | jq -rj .)
if [[ -n "${{ inputs.call }}" ]]; then
verb="call"
elif [[ -n "$check" ]]; then
verb="check"
# check input is used as a trigger; don't pass glob patterns as args
check=""
elif [[ "$shell" != "" ]]; then
verb=""
script=$(mktemp)
Expand All @@ -127,13 +153,13 @@ runs:
echo "dagger-flags=$dagger_flags" >> "$GITHUB_OUTPUT"
echo "args=$args" >> "$GITHUB_OUTPUT"
echo "call=$call" >> "$GITHUB_OUTPUT"
echo "check=$check" >> "$GITHUB_OUTPUT"
- id: exec
if: inputs.call != '' || inputs.shell != '' || inputs.args != ''
if: steps.should-exec.outputs.result == 'true'
shell: bash
env:
INPUT_MODULE: ${{ inputs.module }}
VERB: ${{ steps.assemble.outputs.verb }}
CMD: ${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script }}
SCRIPT: ${{ steps.assemble.outputs.script }}
run: |
tmpout=$(mktemp)
Expand All @@ -142,9 +168,9 @@ runs:
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
dagger \
${{ steps.assemble.outputs.dagger-flags }} \
${{ steps.assemble.outputs.verb }} \
${VERB} \
${INPUT_MODULE:+-m $INPUT_MODULE} \
${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script }}; } 1> >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2)
${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script || steps.assemble.outputs.check }}; } 1> >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2)

{
# we need a delim that doesn't appear in the output - a hash of the
Expand All @@ -167,7 +193,7 @@ runs:
summary_content(){
echo -e "## Command\n"
echo '```bash'
cmd="dagger $VERB $CMD"
cmd="dagger $VERB ${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script || steps.assemble.outputs.check }}"
if [[ -n "$INPUT_MODULE" ]]; then
echo -e -E "DAGGER_MODULE=\"$INPUT_MODULE\" $cmd"
else
Expand Down