Skip to content

Commit b8d582f

Browse files
committed
Tackled code rabbit suggestions
- Fixed moving git ref given to external checks - Swicthed to gaining external workflow run ID direct from API - Started passing this repos workflow run ID to the external run for tracking purposes
1 parent bd944a1 commit b8d582f

1 file changed

Lines changed: 12 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -758,33 +758,18 @@ jobs:
758758
REPO="TryGhost/traffic-analytics-infra"
759759
WORKFLOW="tinybird.yml"
760760
BRANCH="main"
761-
DISPATCHED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
762-
763-
gh workflow run "$WORKFLOW" \
764-
--repo "$REPO" \
765-
--ref "$BRANCH" \
766-
-f ghost_ref='${{ github.ref }}' \
767-
-f run_local_tests='false'
768-
769-
RUN_ID=""
770-
RUN_URL=""
771-
772-
for attempt in {1..30}; do
773-
RUN_ID=$(gh run list \
774-
--repo "$REPO" \
775-
--workflow "$WORKFLOW" \
776-
--branch "$BRANCH" \
777-
--event workflow_dispatch \
778-
--json databaseId,createdAt,url \
779-
--jq 'map(select(.createdAt >= "'"$DISPATCHED_AT"'")) | sort_by(.createdAt) | last | .databaseId // empty')
780-
781-
if [ -n "$RUN_ID" ]; then
782-
RUN_URL=$(gh run view "$RUN_ID" --repo "$REPO" --json url --jq '.url')
783-
break
784-
fi
785-
786-
sleep 5
787-
done
761+
DISPATCH_RESPONSE=$(gh api \
762+
--method POST \
763+
-H "Accept: application/vnd.github+json" \
764+
"repos/$REPO/actions/workflows/$WORKFLOW/dispatches" \
765+
-f ref="$BRANCH" \
766+
-F return_run_details=true \
767+
-F inputs[ghost_ref]='${{ github.sha }}' \
768+
-F inputs[caller_run_id]='${{ github.run_id }}' \
769+
-F inputs[run_local_tests]=false)
770+
771+
RUN_ID=$(printf '%s' "$DISPATCH_RESPONSE" | jq -r '.workflow_run_id // empty')
772+
RUN_URL=$(printf '%s' "$DISPATCH_RESPONSE" | jq -r '.html_url // .run_url // empty')
788773
789774
if [ -z "$RUN_ID" ]; then
790775
echo "::error::Unable to find the triggered workflow run in $REPO"

0 commit comments

Comments
 (0)