Skip to content

Commit dc42441

Browse files
committed
feat: add traceURL output
Signed-off-by: Justin Chadwell <me@jedevc.com>
1 parent 71c85a5 commit dc42441

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

.github/workflows/test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,50 @@ jobs:
8080
exit 1
8181
fi
8282
83+
traceurl:
84+
runs-on: "ubuntu-latest"
85+
steps:
86+
- uses: actions/checkout@v4
87+
- name: "TraceURL with cloud-token"
88+
id: traceurl-token
89+
uses: ./
90+
with:
91+
version: latest
92+
verb: core
93+
args: version
94+
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
95+
- name: "Check traceURL output (should be set)"
96+
run: |
97+
echo token1: ${{ secrets.DAGGER_CLOUD_TOKEN }}
98+
echo token2: ${{ variables.DAGGER_CLOUD_TOKEN }}
99+
echo "----"
100+
url='${{ steps.traceurl-token.outputs.traceURL }}'
101+
if [[ "$url" =~ ^https://dagger.cloud/.+/traces/.+ ]]; then
102+
echo "traceURL found: $url"
103+
exit 0
104+
else
105+
echo "traceURL not found"
106+
exit 1
107+
fi
108+
- name: "TraceURL without cloud-token"
109+
id: traceurl-nil
110+
uses: ./
111+
with:
112+
version: latest
113+
verb: core
114+
args: version
115+
- name: "Check traceURL output (should NOT be set)"
116+
run: |
117+
url='${{ steps.traceurl-nil.outputs.traceURL }}'
118+
if [[ "$url" =~ ^https://dagger.cloud/traces/setup ]]; then
119+
echo "traceURL correctly not set"
120+
exit 0
121+
else
122+
echo "traceURL was set: $url"
123+
exit 1
124+
fi
125+
126+
83127
version:
84128
runs-on: "ubuntu-latest"
85129
steps:
@@ -156,6 +200,7 @@ jobs:
156200
echo "does not match"
157201
exit 1
158202
fi
203+
159204
call:
160205
runs-on: "ubuntu-latest"
161206
steps:
@@ -176,6 +221,7 @@ jobs:
176221
echo "does not match"
177222
exit 1
178223
fi
224+
179225
nocall:
180226
runs-on: "ubuntu-latest"
181227
steps:
@@ -185,3 +231,4 @@ jobs:
185231
- name: "Test Install"
186232
run: |
187233
dagger core version
234+

action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ outputs:
4444
output:
4545
description: "Job output"
4646
value: ${{ steps.exec.outputs.stdout }}
47+
traceURL:
48+
description: "Dagger Cloud trace URL"
49+
value: ${{ steps.exec.outputs.traceURL }}
4750
runs:
4851
using: "composite"
4952
steps:
@@ -79,13 +82,14 @@ runs:
7982
INPUT_MODULE: ${{ inputs.module }}
8083
run: |
8184
tmpout=$(mktemp)
85+
tmperr=$(mktemp)
8286
cd ${{ inputs.workdir }} && { \
8387
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
8488
dagger \
8589
${{ inputs.dagger-flags }} \
8690
${{ inputs.verb }} \
8791
${INPUT_MODULE:+-m $INPUT_MODULE} \
88-
${{ inputs.args || inputs.call }}; } | tee "${tmpout}"
92+
${{ inputs.args || inputs.call }}; } 1> >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2)
8993
9094
{
9195
# we need a delim that doesn't appear in the output - a hash of the
@@ -98,6 +102,12 @@ runs:
98102
echo "${delim}"
99103
} >> "$GITHUB_OUTPUT"
100104
105+
# Extract trace URL from stderr and set as traceURL output
106+
trace_url=$((grep -Eo 'https://dagger.cloud(/[^ ]+/traces/[a-zA-Z0-9]+|/traces/setup)' "${tmperr}" || true) | head -n1)
107+
if [[ -n "$trace_url" ]]; then
108+
echo "traceURL=$trace_url" >> "$GITHUB_OUTPUT"
109+
fi
110+
101111
- if: (inputs.call != '' || inputs.args != '') && inputs.engine-stop == 'true'
102112
shell: bash
103113
run: |

0 commit comments

Comments
 (0)