@@ -10,6 +10,18 @@ inputs:
1010 description : Original issue comment body. Flags such as no-cache-sim, latest-device, and quality=tiny are honored.
1111 required : false
1212 default : simdeck run ios
13+ command_comment_id :
14+ description : GitHub issue comment id that triggered the session. When set, the action reacts to this comment immediately.
15+ required : false
16+ default : " "
17+ command_comment_author :
18+ description : GitHub username to mention when the URL is ready.
19+ required : false
20+ default : " "
21+ command_reaction :
22+ description : Reaction to add to the triggering comment. Use one of +1, -1, laugh, confused, heart, hooray, rocket, eyes.
23+ required : false
24+ default : eyes
1325 pr_sha :
1426 description : Optional pull request head SHA. When omitted, the action resolves it through the GitHub API.
1527 required : false
8294 PR_NUMBER_VALUE : ${{ inputs.pr_number }}
8395 PR_SHA_INPUT_VALUE : ${{ inputs.pr_sha }}
8496 SIMDECK_COMMENT_BODY_VALUE : ${{ inputs.command }}
97+ COMMAND_COMMENT_ID_VALUE : ${{ inputs.command_comment_id }}
98+ COMMAND_COMMENT_AUTHOR_VALUE : ${{ inputs.command_comment_author }}
99+ COMMAND_REACTION_VALUE : ${{ inputs.command_reaction }}
85100 SIMDECK_BUNDLE_ID_VALUE : ${{ inputs.bundle_id }}
86101 SIMDECK_PORT_VALUE : ${{ inputs.simdeck_port }}
87102 SIMDECK_PACKAGE_VALUE : ${{ inputs.simdeck_package }}
@@ -114,6 +129,9 @@ runs:
114129 write_env "PR_NUMBER" "${PR_NUMBER_VALUE}"
115130 write_env "PR_SHA_INPUT" "${PR_SHA_INPUT_VALUE}"
116131 write_env "SIMDECK_COMMENT_BODY" "${SIMDECK_COMMENT_BODY_VALUE}"
132+ write_env "COMMAND_COMMENT_ID" "${COMMAND_COMMENT_ID_VALUE}"
133+ write_env "COMMAND_COMMENT_AUTHOR" "${COMMAND_COMMENT_AUTHOR_VALUE}"
134+ write_env "COMMAND_REACTION" "${COMMAND_REACTION_VALUE}"
117135 write_env "SIMDECK_BUNDLE_ID" "${SIMDECK_BUNDLE_ID_VALUE}"
118136 write_env "SIMDECK_PORT" "${SIMDECK_PORT_VALUE}"
119137 write_env "SIMDECK_PACKAGE" "${SIMDECK_PACKAGE_VALUE}"
@@ -128,24 +146,17 @@ runs:
128146 write_env "ARTIFACT_PREFIX" "${ARTIFACT_PREFIX_VALUE}"
129147 write_env "ARTIFACT_NAME_INPUT" "${ARTIFACT_NAME_INPUT_VALUE}"
130148 write_env "FORCE_JAVASCRIPT_ACTIONS_TO_NODE24" "true"
131- - name : Create status comment and resolve flags
149+ - name : React to command and resolve flags
132150 shell : bash
133151 run : |
134152 set -euo pipefail
135- status_body="Starting a SimDeck iOS session for this pull request. I will update this comment with the tunnel URL when it is ready."
136- status_comment_id=""
137153
138- for attempt in {1..5}; do
139- if comment_id="$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" -f body="${status_body}" --jq '.id')"; then
140- status_comment_id="${comment_id}"
141- echo "SIMDECK_STATUS_COMMENT_ID=${status_comment_id}" >> "${GITHUB_ENV}"
142- break
143- fi
144- sleep $((attempt * 5))
145- done
146-
147- if [[ -z "${status_comment_id}" ]]; then
148- exit 1
154+ if [[ -n "${COMMAND_COMMENT_ID:-}" && -n "${COMMAND_REACTION:-}" ]]; then
155+ gh api \
156+ -X POST \
157+ -H "Accept: application/vnd.github+json" \
158+ "repos/${REPO}/issues/comments/${COMMAND_COMMENT_ID}/reactions" \
159+ -f content="${COMMAND_REACTION}" >/dev/null || true
149160 fi
150161
151162 body="${SIMDECK_COMMENT_BODY}"
@@ -536,17 +547,28 @@ runs:
536547 shell : bash
537548 run : |
538549 set -euo pipefail
550+ mention=""
551+ if [[ -n "${COMMAND_COMMENT_AUTHOR:-}" ]]; then
552+ mention="@${COMMAND_COMMENT_AUTHOR} "
553+ fi
554+
539555 cat > comment.md <<'EOF'
540- SimDeck iOS session is ready: [Open SimDeck](${{ steps.stream.outputs.url }}?simdeckToken=${{ steps.stream.outputs.access_token }}&device=${{ env.SIMULATOR_UDID }})
556+ __MENTION__SimDeck iOS session is ready: [Open SimDeck](${{ steps.stream.outputs.url }}?simdeckToken=${{ steps.stream.outputs.access_token }}&device=${{ env.SIMULATOR_UDID }})
541557
542558 The selected simulator is booting and the PR app will launch here once its build artifact is installed.
543559
544560 This session will stop after ${{ inputs.keepalive_seconds }} seconds, or earlier if the simulator shuts down.
545561 EOF
546562
547563 body="$(cat comment.md)"
564+ body="${body/__MENTION__/${mention}}"
548565 for attempt in {1..5}; do
549- if [[ -n "${SIMDECK_STATUS_COMMENT_ID:-}" ]] && gh api -X PATCH "repos/${REPO}/issues/comments/${SIMDECK_STATUS_COMMENT_ID}" -f body="${body}"; then
566+ if [[ -n "${SIMDECK_STATUS_COMMENT_ID:-}" ]]; then
567+ if gh api -X PATCH "repos/${REPO}/issues/comments/${SIMDECK_STATUS_COMMENT_ID}" -f body="${body}"; then
568+ exit 0
569+ fi
570+ elif comment_id="$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" -f body="${body}" --jq '.id')"; then
571+ echo "SIMDECK_STATUS_COMMENT_ID=${comment_id}" >> "${GITHUB_ENV}"
550572 exit 0
551573 fi
552574 sleep $((attempt * 5))
0 commit comments