forked from kurt-code/ga-firebase-distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_output.sh
64 lines (54 loc) · 2.29 KB
/
parse_output.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Input string
output_string=$1
# Regex pattern to match the firebase console uri
firebase_console_regex="https:\/\/console\.firebase\.google\.com\/project\/[^\/]+\/appdistribution\/app\/android:[^\/]+\/releases\/[a-zA-Z0-9]+"
# Regex pattern to match the testing uri
testing_regex="https:\/\/appdistribution\.firebase\.google\.com\/testerapps\/[0-9]+:[^\/]+\/releases\/[a-zA-Z0-9]+"
# Regex pattern to match the binary download uri
binary_download_regex="https:\/\/firebaseappdistribution\.googleapis\.com\/app-binary-downloads\/projects\/[0-9]+\/apps\/[0-9]+:[^\/]+\/releases\/[a-zA-Z0-9]+\/binaries\/[a-zA-Z0-9]+\/app\.apk"
# Check for error in the output string
if [[ "$output_string" =~ "Error" ]]; then
error_message="$output_string"
firebase_console_uri=""
testing_uri=""
binary_download_uri=""
# Print the extracted URLs and error message
echo "FAILED"
echo "Error message: $error_message"
echo "error_message=$error_message" >> "$GITHUB_OUTPUT"
echo "upload_status=failure" >> "$GITHUB_OUTPUT"
# exit 1
else
# Extract firebase console uri
if [[ "$output_string" =~ $firebase_console_regex ]]; then
firebase_console_uri="${BASH_REMATCH[0]}"
fi
# Extract testing uri
if [[ "$output_string" =~ $testing_regex ]]; then
testing_uri="${BASH_REMATCH[0]}"
fi
# Extract binary download uri
if [[ "$output_string" =~ $binary_download_regex ]]; then
binary_download_uri="${BASH_REMATCH[0]}"
fi
# Check if all URLs were extracted successfully
if [[ -z "$firebase_console_uri" || -z "$testing_uri" || -z "$binary_download_uri" ]]; then
error_message="Failed to extract URLs from output string"
echo "WARNING: $output_string"
echo "error_message=$error_message" >> "$GITHUB_OUTPUT"
echo "upload_status=warning" >> "$GITHUB_OUTPUT"
else
error_message=""
echo "SUCCESS"
echo "Firebase Console URI: $firebase_console_uri"
echo "Testing URI: $testing_uri"
echo "Binary Download URI: $binary_download_uri"
echo "error_message=$error_message" >> "$GITHUB_OUTPUT"
echo "upload_status=success" >> "$GITHUB_OUTPUT"
echo "firebase_console_uri=$firebase_console_uri" >> "$GITHUB_OUTPUT"
echo "testing_uri=$testing_uri" >> "$GITHUB_OUTPUT"
echo "binary_download_uri=$binary_download_uri" >> "$GITHUB_OUTPUT"
fi
# exit 0
fi