@@ -159,45 +159,44 @@ if [ -n "$REMOTE" ]; then
159159 assert " $( git status -s -uno) " ' ' ' You have uncommitted changes.'
160160 assert " $( git push --dry-run 2>&1 ) " ' Everything up-to-date' ' You have unpushed changes.'
161161
162- gh workflow run --repo couchbase/docs-infra preview-deploy.yml \
162+ WORKFLOW=preview-deploy.yml
163+ UUID=$( uuidgen)
164+
165+ gh workflow run --repo couchbase/docs-infra $WORKFLOW \
163166 --field preview_repo=${PREVIEW_REPO} \
164167 --field preview_branch=${PREVIEW_BRANCH} \
165168 --field preview_start_path=${PREVIEW_START_PATH} \
166169 --field preview_override=${PREVIEW_OVERRIDE} \
170+ --field uuid=${UUID} \
167171 > /dev/null
168172
169- echo Requested the build at Github
173+ echo Requested the build at Github with UUID $UUID
170174 echo see https://github.com/couchbase/docs-infra/actions/workflows/preview-deploy.yml
171175 echo
172176 echo Visit ' https://preview.docs-test.couchbase.com/builds.html' to see all completed builds
173177 echo
174178
175- for i in {1..10}
176- do
177- echo " Polling github..."
178- sleep 7 # try to avoid showing an earlier run
179- if RUN=$(
180- gh run list --repo=couchbase/docs-infra \
181- --workflow=preview-deploy.yml \
182- --created $( date ' +%Y-%m-%d' ) \
183- --limit 3 \
184- --json url,displayTitle,createdAt \
185- --template $TEMPLATE \
186- ' read -r -d ' ' TEMPLATE <<EOT
187- {{range .}}
188- {{.url}}
189- {{ .displayTitle}}
190- {{ (timeago .createdAt)}}
191- {{end}}' \
192- | grep --context=1 " /${PREVIEW_REPO} -${PREVIEW_BRANCH} /" \
193- | head -n 1 ) ; then
194- # https://github.com/couchbase/docs-infra/actions/runs/14029636191
195- echo " Opening $RUN in browser"
196- open $RUN
179+
180+ for i in {1..10}; do
181+ echo Polling github...
182+ URL=$( gh run list \
183+ --repo couchbase/docs-infra \
184+ -w $WORKFLOW \
185+ --json displayTitle,url,databaseId \
186+ | jq -r \
187+ --arg UUID $UUID \
188+ ' .[] | select(.displayTitle | test($UUID))| .url' )
189+ if [ -n " $URL " ]; then
190+ echo Opening $URL in your web browser
191+ # or could `gh run watch $databaseId`
192+ open $URL
197193 exit 0
198194 fi
199- done
200195
196+ sleep 3
197+ done
198+ echo Timed out. Check Github actions
199+ exit 1
201200
202201else
203202 export PREVIEW_GITHUB_REMOTE=$( git remote get-url origin 2> /dev/null)
0 commit comments