Skip to content

Commit bdd3644

Browse files
committed
Add get_available_devices()
1 parent 9a06cad commit bdd3644

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

.github/workflows/scripts/browserstack-app-automate.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RETRY_INTERVAL=10
99
# API URLs
1010
TRIGGER_URL="https://api-cloud.browserstack.com/app-automate/flutter-integration-tests/v2/android/build"
1111
STATUS_URL="https://api-cloud.browserstack.com/app-automate/flutter-integration-tests/v2/android/builds"
12+
DEVICES_URL="https://api-cloud.browserstack.com/app-automate/devices"
1213

1314
# Retrieve vars from environment variables
1415
CREDENTIALS="${BROWSERSTACK_CREDENTIALS:-}"
@@ -24,13 +25,25 @@ if [[ -z "$CREDENTIALS" ]]; then
2425
exit 1
2526
fi
2627

27-
if [[ -z "$APP" || -z "$TEST_SUITE" || -z "$BUILD_TAG" || -z "$DEVICES" ]]; then
28+
if [[ -z "$PROJECT" || -z "$APP" || -z "$TEST_SUITE" || -z "$BUILD_TAG" || -z "$DEVICES" ]]; then
2829
echo "Error: Environment variables"\
2930
"BROWSERSTACK_PROJECT, BROWSERSTACK_APP, BROWSERSTACK_TEST_SUITE, BROWSERSTACK_BUILD_TAG and BROWSERSTACK_DEVICES"\
3031
"must be set."
3132
exit 1
3233
fi
3334

35+
# Function to get a list of available devices
36+
get_available_devices() {
37+
local response=$(curl -s -u "$CREDENTIALS" -X GET "$DEVICES_URL")
38+
if [[ -z "$response" ]]; then
39+
echo "Failed to fetch available devices."
40+
return 1
41+
fi
42+
43+
echo "Available devices:"
44+
echo "$response" | jq -r '.[] | "Device: " + .device + ", OS Version: " + .os_version'
45+
}
46+
3447
# Function to trigger the build
3548
trigger_build() {
3649
local response=$(curl -s -u "$CREDENTIALS" \
@@ -91,6 +104,10 @@ check_build_status() {
91104
}
92105

93106
# Main
107+
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
108+
get_available_devices
109+
fi
110+
94111
if ! BUILD_ID=$(trigger_build); then
95112
echo "Trigger build failed. Message: $BUILD_ID"
96113
exit 9

0 commit comments

Comments
 (0)