-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add stop-on-run-finished input and session-url output #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 83
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 260
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 241
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 2736
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 1105
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 722
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 90
🏁 Script executed:
Repository: ambient-code/ambient-action
Length of output: 4086
Move
session-urloutput after Python execution completes and use safe writes for$GITHUB_OUTPUT.Currently,
session-urlis emitted at line 167 before the Python command executes at line 173. If Python fails and no output file is created, the pre-emitted URL persists in$GITHUB_OUTPUTwhile other fields (session-name, session-phase) indicate failure. This creates inconsistent, misleading output for downstream workflows.Additionally, direct
echo key=valuewrites at lines 167, 181–183, 188, 190, and 201 are unsafe for special characters in$INPUT_API_URL,$INPUT_PROJECT, or$INPUT_SESSION_NAME. Use GitHub Actions' safe delimiter pattern (heredoc withGHEOF) for all output writes, capture the Python exit code, and emit outputs only after confirming success.🔧 Proposed fix
if [ -n "$INPUT_SESSION_NAME" ]; then ARGS+=(--session-name "$INPUT_SESSION_NAME") - # Pre-set session-url for reuse case (output file may not have it) - BASE_URL=$(echo "$INPUT_API_URL" | sed 's|/api$||; s|/api/$||') - echo "session-url=${BASE_URL}/projects/${INPUT_PROJECT}/sessions/${INPUT_SESSION_NAME}" >> "$GITHUB_OUTPUT" fi @@ - python3 "${GITHUB_ACTION_PATH}/create_session.py" "${ARGS[@]}" + set +e + python3 "${GITHUB_ACTION_PATH}/create_session.py" "${ARGS[@]}" + PY_EXIT=$? + set -e + + write_output_kv() { + local key="$1" + local value="$2" + { + echo "${key}<<GHEOF" + echo "$value" + echo "GHEOF" + } >> "$GITHUB_OUTPUT" + } @@ - echo "session-name=$SESSION_NAME" >> "$GITHUB_OUTPUT" - echo "session-uid=$SESSION_UID" >> "$GITHUB_OUTPUT" - echo "session-phase=$SESSION_PHASE" >> "$GITHUB_OUTPUT" + write_output_kv "session-name" "$SESSION_NAME" + write_output_kv "session-uid" "$SESSION_UID" + write_output_kv "session-phase" "$SESSION_PHASE" @@ - # Construct session URL from API URL - if [ -n "$SESSION_NAME" ]; then - BASE_URL=$(echo "$INPUT_API_URL" | sed 's|/api$||; s|/api/$||') - echo "session-url=${BASE_URL}/projects/${INPUT_PROJECT}/sessions/${SESSION_NAME}" >> "$GITHUB_OUTPUT" - else - echo "session-url=" >> "$GITHUB_OUTPUT" - fi + if [ -n "$SESSION_NAME" ]; then + BASE_URL=$(echo "$INPUT_API_URL" | sed 's|/api$||; s|/api/$||') + write_output_kv "session-url" "${BASE_URL}/projects/${INPUT_PROJECT}/sessions/${SESSION_NAME}" + else + write_output_kv "session-url" "" + fi @@ else - echo "session-name=" >> "$GITHUB_OUTPUT" - echo "session-uid=" >> "$GITHUB_OUTPUT" - echo "session-url=" >> "$GITHUB_OUTPUT" - echo "session-phase=CreateFailed" >> "$GITHUB_OUTPUT" - echo "session-result=" >> "$GITHUB_OUTPUT" + write_output_kv "session-name" "" + write_output_kv "session-uid" "" + write_output_kv "session-url" "" + write_output_kv "session-phase" "CreateFailed" + write_output_kv "session-result" "" fi + + exit "$PY_EXIT"Also applies to: 173, 185–191, 201
🤖 Prompt for AI Agents