mirror of
https://github.com/dagger/dagger-for-github.git
synced 2025-12-31 12:49:46 +11:00
Add summary for executable verbs (#192)
This commit is contained in:
parent
4f6f256cec
commit
27bae3a184
3 changed files with 112 additions and 12 deletions
43
.github/workflows/test.yml
vendored
43
.github/workflows/test.yml
vendored
|
|
@ -239,6 +239,49 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
summary-path:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: "Test summary-path"
|
||||||
|
id: test-summary-path
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
verb: core
|
||||||
|
args: version
|
||||||
|
summary-path: "/tmp/custom-summary.md"
|
||||||
|
- name: "Check custom summary file"
|
||||||
|
run: |
|
||||||
|
if [[ -f "/tmp/custom-summary.md" ]] && [[ -s "/tmp/custom-summary.md" ]]; then
|
||||||
|
echo "Custom summary file exists and has content"
|
||||||
|
echo "Content preview:"
|
||||||
|
head -10 "/tmp/custom-summary.md"
|
||||||
|
else
|
||||||
|
echo "Custom summary file missing or empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
enable-github-summary:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: "Test enable-github-summary=true (default)"
|
||||||
|
id: test-github-summary-enabled
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
verb: core
|
||||||
|
args: version
|
||||||
|
- name: "Check github summary enabled"
|
||||||
|
run: |
|
||||||
|
if [[ -n "${GITHUB_STEP_SUMMARY}" ]]; then
|
||||||
|
echo "GitHub step summary was written (default behavior)"
|
||||||
|
else
|
||||||
|
echo "GitHub step summary not written when it should have been"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
nocall:
|
nocall:
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ By setting the version to `latest`, this action will install the latest version
|
||||||
### All `with:` input parameter options
|
### All `with:` input parameter options
|
||||||
|
|
||||||
| Key | Description | Required | Default |
|
| Key | Description | Required | Default |
|
||||||
| --------------- | ----------------------------------------------------------------- | -------- | ------------------ |
|
| ------------------------------- | ----------------------------------------------------------------- | -------- | ------------------ |
|
||||||
| `version` | Dagger Version. Use semver vX.Y.Z or 'latest' | true | 'latest' |
|
| `version` | Dagger Version. Use semver vX.Y.Z or 'latest' | true | 'latest' |
|
||||||
| `commit` | Dagger Dev Commit (overrides `version`) | false | '' |
|
| `commit` | Dagger Dev Commit (overrides `version`) | false | '' |
|
||||||
| `dagger-flags` | Dagger CLI Flags | false | '--progress plain' |
|
| `dagger-flags` | Dagger CLI Flags | false | '--progress plain' |
|
||||||
|
|
@ -55,6 +55,8 @@ By setting the version to `latest`, this action will install the latest version
|
||||||
| `args` | Arguments to pass to CLI | false | '' |
|
| `args` | Arguments to pass to CLI | false | '' |
|
||||||
| `call` | Arguments to pass to CLI (Alias for args with verb:call) | 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 | '' |
|
| `shell` | Arguments to pass to CLI (Alias for args with verb:shell) | 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' |
|
||||||
|
|
||||||
### All output variables
|
### All output variables
|
||||||
|
|
||||||
|
|
|
||||||
55
action.yml
55
action.yml
|
|
@ -45,6 +45,14 @@ inputs:
|
||||||
description: "Function and arguments for dagger shell"
|
description: "Function and arguments for dagger shell"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
summary-path:
|
||||||
|
description: "File path to write the job summary"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
enable-github-summary:
|
||||||
|
description: "Whether to write summary to GITHUB_STEP_SUMMARY"
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
outputs:
|
outputs:
|
||||||
output:
|
output:
|
||||||
description: "Job output"
|
description: "Job output"
|
||||||
|
|
@ -115,6 +123,9 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
INPUT_MODULE: ${{ inputs.module }}
|
INPUT_MODULE: ${{ inputs.module }}
|
||||||
|
VERB: ${{ steps.assemble.outputs.verb }}
|
||||||
|
CMD: ${{ inputs.args || inputs.call || steps.assemble.outputs.script }}
|
||||||
|
SCRIPT: ${{ steps.assemble.outputs.script }}
|
||||||
run: |
|
run: |
|
||||||
tmpout=$(mktemp)
|
tmpout=$(mktemp)
|
||||||
tmperr=$(mktemp)
|
tmperr=$(mktemp)
|
||||||
|
|
@ -142,3 +153,47 @@ runs:
|
||||||
if [[ -n "$trace_url" ]]; then
|
if [[ -n "$trace_url" ]]; then
|
||||||
echo "traceURL=$trace_url" >> "$GITHUB_OUTPUT"
|
echo "traceURL=$trace_url" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Generate job summary content
|
||||||
|
summary_content(){
|
||||||
|
echo -e "## Command\n"
|
||||||
|
echo '```bash'
|
||||||
|
cmd="dagger $VERB $CMD"
|
||||||
|
if [[ -n "$INPUT_MODULE" ]]; then
|
||||||
|
echo -e -E "DAGGER_MODULE=\"$INPUT_MODULE\" $cmd"
|
||||||
|
else
|
||||||
|
echo -e -E "$cmd"
|
||||||
|
fi
|
||||||
|
echo '```'
|
||||||
|
if [[ -n "$SCRIPT" ]]; then
|
||||||
|
echo -e "### Script\n"
|
||||||
|
echo '```bash'
|
||||||
|
cat "$SCRIPT"
|
||||||
|
echo -e "\n"
|
||||||
|
echo '```'
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "## Dagger trace\n"
|
||||||
|
if [[ -n "$trace_url" ]]; then
|
||||||
|
echo "[$trace_url]($trace_url)"
|
||||||
|
else
|
||||||
|
echo "No trace available. To setup: [https://dagger.cloud/traces/setup](https://dagger.cloud/traces/setup)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "## Dagger version\n"
|
||||||
|
echo '```bash'
|
||||||
|
dagger version || true
|
||||||
|
echo '```'
|
||||||
|
|
||||||
|
echo -e "---\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write to custom summary path if specified
|
||||||
|
if [[ -n "${{ inputs.summary-path }}" ]]; then
|
||||||
|
summary_content > "${{ inputs.summary-path }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write to GitHub step summary if enabled (default: true)
|
||||||
|
if [[ "${{ inputs.enable-github-summary }}" == "true" ]]; then
|
||||||
|
summary_content > "${GITHUB_STEP_SUMMARY}"
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue