File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,11 +12,28 @@ TOOLS_MARKER_FILE="$MARKER_DIR/tools"
1212
1313sudo mkdir -p " $MARKER_DIR "
1414
15+ # Check if TEMPLATE_PAT is set
16+ if [ -z " $TEMPLATE_PAT " ]; then
17+ echo " TEMPLATE_PAT environment variable is not set. Skipping tools update."
18+ exit 0
19+ fi
20+
1521# Fetch the latest release information
1622LATEST_RELEASE=$( curl -s -H " Authorization: token $TEMPLATE_PAT " https://api.github.com/repos/github/spark-template/releases/latest)
1723
24+ # Check if the API call succeeded
25+ if [ $? -ne 0 ] || [ -z " $LATEST_RELEASE " ]; then
26+ echo " Failed to fetch release information from GitHub. Skipping tools update."
27+ exit 0
28+ fi
29+
1830# Check if marker file exists and has the same release ID
1931RELEASE_ID=$( echo " $LATEST_RELEASE " | jq -r ' .id' )
32+ if [ " $RELEASE_ID " == " null" ] || [ -z " $RELEASE_ID " ]; then
33+ echo " Invalid release data received from GitHub. Skipping tools update."
34+ exit 0
35+ fi
36+
2037if [ -f " $RELEASE_MARKER_FILE " ] && [ " $( cat " $RELEASE_MARKER_FILE " ) " == " $RELEASE_ID " ]; then
2138 echo " Already at the latest release. Skipping download."
2239 exit 0
@@ -28,6 +45,13 @@ TEMP_DIR=$(mktemp -d)
2845cd $TEMP_DIR
2946
3047DOWNLOAD_URL=$( echo " $LATEST_RELEASE " | jq -r ' .assets[0].url' )
48+ if [ " $DOWNLOAD_URL " == " null" ] || [ -z " $DOWNLOAD_URL " ]; then
49+ echo " No download URL found in release data. Skipping tools update."
50+ cd - > /dev/null
51+ rm -rf $TEMP_DIR
52+ exit 0
53+ fi
54+
3155curl -L -o dist.zip -H " Authorization: token $TEMPLATE_PAT " -H " Accept: application/octet-stream" " $DOWNLOAD_URL "
3256
3357unzip -o dist.zip
You can’t perform that action at this time.
0 commit comments