Skip to content

Commit 27bae3a

Browse files
authored
Add summary for executable verbs (#192)
1 parent 4f6f256 commit 27bae3a

File tree

3 files changed

+112
-12
lines changed

3 files changed

+112
-12
lines changed

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,49 @@ jobs:
239239
exit 1
240240
fi
241241
242+
summary-path:
243+
runs-on: "ubuntu-latest"
244+
steps:
245+
- uses: actions/checkout@v4
246+
- name: "Test summary-path"
247+
id: test-summary-path
248+
uses: ./
249+
with:
250+
version: latest
251+
verb: core
252+
args: version
253+
summary-path: "/tmp/custom-summary.md"
254+
- name: "Check custom summary file"
255+
run: |
256+
if [[ -f "/tmp/custom-summary.md" ]] && [[ -s "/tmp/custom-summary.md" ]]; then
257+
echo "Custom summary file exists and has content"
258+
echo "Content preview:"
259+
head -10 "/tmp/custom-summary.md"
260+
else
261+
echo "Custom summary file missing or empty"
262+
exit 1
263+
fi
264+
265+
enable-github-summary:
266+
runs-on: "ubuntu-latest"
267+
steps:
268+
- uses: actions/checkout@v4
269+
- name: "Test enable-github-summary=true (default)"
270+
id: test-github-summary-enabled
271+
uses: ./
272+
with:
273+
version: latest
274+
verb: core
275+
args: version
276+
- name: "Check github summary enabled"
277+
run: |
278+
if [[ -n "${GITHUB_STEP_SUMMARY}" ]]; then
279+
echo "GitHub step summary was written (default behavior)"
280+
else
281+
echo "GitHub step summary not written when it should have been"
282+
exit 1
283+
fi
284+
242285
nocall:
243286
runs-on: "ubuntu-latest"
244287
steps:

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ By setting the version to `latest`, this action will install the latest version
4343

4444
### All `with:` input parameter options
4545

46-
| Key | Description | Required | Default |
47-
| --------------- | ----------------------------------------------------------------- | -------- | ------------------ |
48-
| `version` | Dagger Version. Use semver vX.Y.Z or 'latest' | true | 'latest' |
49-
| `commit` | Dagger Dev Commit (overrides `version`) | false | '' |
50-
| `dagger-flags` | Dagger CLI Flags | false | '--progress plain' |
51-
| `verb` | CLI verb (call, run, download, up, functions, shell, query) | false | 'call' |
52-
| `workdir` | The working directory in which to run the Dagger CLI | false | '.' |
53-
| `cloud-token` | Dagger Cloud Token | false | '' |
54-
| `module` | Dagger module to call. Local or Git | false | '' |
55-
| `args` | Arguments to pass to CLI | false | '' |
56-
| `call` | Arguments to pass to CLI (Alias for args with verb:call) | false | '' |
57-
| `shell` | Arguments to pass to CLI (Alias for args with verb:shell) | false | '' |
46+
| Key | Description | Required | Default |
47+
| ------------------------------- | ----------------------------------------------------------------- | -------- | ------------------ |
48+
| `version` | Dagger Version. Use semver vX.Y.Z or 'latest' | true | 'latest' |
49+
| `commit` | Dagger Dev Commit (overrides `version`) | false | '' |
50+
| `dagger-flags` | Dagger CLI Flags | false | '--progress plain' |
51+
| `verb` | CLI verb (call, run, download, up, functions, shell, query) | false | 'call' |
52+
| `workdir` | The working directory in which to run the Dagger CLI | false | '.' |
53+
| `cloud-token` | Dagger Cloud Token | false | '' |
54+
| `module` | Dagger module to call. Local or Git | false | '' |
55+
| `args` | Arguments to pass to CLI | false | '' |
56+
| `call` | Arguments to pass to CLI (Alias for args with verb:call) | false | '' |
57+
| `shell` | Arguments to pass to CLI (Alias for args with verb:shell) | false | '' |
58+
| `summary-path` | File path to write the job summary to | false | '' |
59+
| `enable-github-summary` | Whether to automatically write a GitHub Actions job summary | false | 'false' |
5860

5961
### All output variables
6062

action.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ inputs:
4545
description: "Function and arguments for dagger shell"
4646
required: false
4747
default: ""
48+
summary-path:
49+
description: "File path to write the job summary"
50+
required: false
51+
default: ""
52+
enable-github-summary:
53+
description: "Whether to write summary to GITHUB_STEP_SUMMARY"
54+
required: false
55+
default: "false"
4856
outputs:
4957
output:
5058
description: "Job output"
@@ -115,6 +123,9 @@ runs:
115123
shell: bash
116124
env:
117125
INPUT_MODULE: ${{ inputs.module }}
126+
VERB: ${{ steps.assemble.outputs.verb }}
127+
CMD: ${{ inputs.args || inputs.call || steps.assemble.outputs.script }}
128+
SCRIPT: ${{ steps.assemble.outputs.script }}
118129
run: |
119130
tmpout=$(mktemp)
120131
tmperr=$(mktemp)
@@ -142,3 +153,47 @@ runs:
142153
if [[ -n "$trace_url" ]]; then
143154
echo "traceURL=$trace_url" >> "$GITHUB_OUTPUT"
144155
fi
156+
157+
# Generate job summary content
158+
summary_content(){
159+
echo -e "## Command\n"
160+
echo '```bash'
161+
cmd="dagger $VERB $CMD"
162+
if [[ -n "$INPUT_MODULE" ]]; then
163+
echo -e -E "DAGGER_MODULE=\"$INPUT_MODULE\" $cmd"
164+
else
165+
echo -e -E "$cmd"
166+
fi
167+
echo '```'
168+
if [[ -n "$SCRIPT" ]]; then
169+
echo -e "### Script\n"
170+
echo '```bash'
171+
cat "$SCRIPT"
172+
echo -e "\n"
173+
echo '```'
174+
fi
175+
176+
echo -e "## Dagger trace\n"
177+
if [[ -n "$trace_url" ]]; then
178+
echo "[$trace_url]($trace_url)"
179+
else
180+
echo "No trace available. To setup: [https://dagger.cloud/traces/setup](https://dagger.cloud/traces/setup)"
181+
fi
182+
183+
echo -e "## Dagger version\n"
184+
echo '```bash'
185+
dagger version || true
186+
echo '```'
187+
188+
echo -e "---\n"
189+
}
190+
191+
# Write to custom summary path if specified
192+
if [[ -n "${{ inputs.summary-path }}" ]]; then
193+
summary_content > "${{ inputs.summary-path }}"
194+
fi
195+
196+
# Write to GitHub step summary if enabled (default: true)
197+
if [[ "${{ inputs.enable-github-summary }}" == "true" ]]; then
198+
summary_content > "${GITHUB_STEP_SUMMARY}"
199+
fi

0 commit comments

Comments
 (0)