Skip to content

Commit cec32ea

Browse files
committed
Updated Tinybird CI to trigger & follow infra workflow
Ghost CI now triggers & waits for the dispatched traffic analytics workflow and mirrors its final result.
1 parent 653e97e commit cec32ea

3 files changed

Lines changed: 49 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,6 @@ jobs:
740740
image: tinybirdco/tinybird-local:latest
741741
ports:
742742
- 7181:7181
743-
env:
744-
TINYBIRD_HOST: ${{ secrets.TINYBIRD_HOST }}
745-
TINYBIRD_TOKEN: ${{ secrets.TINYBIRD_TOKEN }}
746-
TINYBIRD_HOST_STAGING: ${{ secrets.TINYBIRD_HOST_STAGING }}
747-
TINYBIRD_TOKEN_STAGING: ${{ secrets.TINYBIRD_TOKEN_STAGING }}
748743
steps:
749744
- uses: actions/checkout@v6
750745
- name: Install Tinybird CLI
@@ -753,10 +748,51 @@ jobs:
753748
run: tb build
754749
- name: Test project
755750
run: tb test run
756-
- name: Deployment check - Staging
757-
run: tb --cloud --host ${{ env.TINYBIRD_HOST_STAGING }} --token ${{ env.TINYBIRD_TOKEN_STAGING }} deploy --check
758-
- name: Deployment check - Production
759-
run: tb --cloud --host ${{ env.TINYBIRD_HOST }} --token ${{ env.TINYBIRD_TOKEN }} deploy --check
751+
- name: Trigger and watch traffic analytics infra Tinybird workflow
752+
if: github.repository == 'TryGhost/Ghost'
753+
env:
754+
GH_TOKEN: ${{ secrets.TRAFFIC_ANALYTICS_GITHUB_TOKEN }}
755+
run: |
756+
set -euo pipefail
757+
758+
REPO="TryGhost/traffic-analytics-infra"
759+
WORKFLOW="tinybird.yml"
760+
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
788+
789+
if [ -z "$RUN_ID" ]; then
790+
echo "::error::Unable to find the triggered workflow run in $REPO"
791+
exit 1
792+
fi
793+
794+
echo "Watching remote workflow run: $RUN_URL"
795+
gh run watch "$RUN_ID" --repo "$REPO" --exit-status
760796
761797
job_ghost-cli:
762798
name: Ghost-CLI tests
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE test_node
2+
SQL >
3+
SELECT 1 AS ok

ghost/core/core/server/data/tinybird/tests/api_kpis.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
- name: Date range
34
description: All fixture data
45
parameters: site_uuid=mock_site_uuid&date_from=2100-01-01&date_to=2100-01-07

0 commit comments

Comments
 (0)