Skip to content

Commit 84a6191

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 54366ef commit 84a6191

1 file changed

Lines changed: 19 additions & 27 deletions

File tree

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)