11name : " Deploy to StaticHost.eu"
2- description : " Deploy a static site to StaticHost.eu using the official CLI tool "
2+ description : " Deploy a static site to StaticHost.eu by securely zipping and uploading a directory "
33branding :
44 icon : " upload-cloud"
55 color : " blue"
66
77inputs :
88 api-token :
9- description : " StaticHost.eu API token (create one at https://builder.statichost.eu/account) "
9+ description : " StaticHost.eu API token"
1010 required : true
1111 site-name :
1212 description : " Name of the site on StaticHost.eu"
@@ -21,26 +21,44 @@ runs:
2121 - name : Deploy to StaticHost.eu
2222 shell : bash
2323 env :
24- # The shcli bash script looks for this exact environment variable to authenticate
2524 STATICHOST_APIKEY : ${{ inputs.api-token }}
2625 run : |
2726 set -euo pipefail
2827
28+ # Map GitHub Action inputs to the variables the script expects
2929 SITE_NAME="${{ inputs.site-name }}"
3030 DIRECTORY="${{ inputs.path }}"
3131
32+ # Check if directory exists
3233 if [ ! -d "$DIRECTORY" ]; then
33- echo "::error::Directory '$DIRECTORY' does not exist"
34- exit 1
34+ echo "::error::Directory '$DIRECTORY' does not exist"
35+ exit 1
3536 fi
3637
37- echo "Downloading the official StaticHost CLI tool..."
38- curl -s -o shcli https://www.statichost.eu/shcli
39- chmod +x shcli
38+ # Check for API key
39+ if [ -z "${STATICHOST_APIKEY:-}" ]; then
40+ echo "::error::STATICHOST_APIKEY environment variable is not set"
41+ exit 1
42+ fi
43+
44+ # Set builder hostname
45+ BUILDER_HOST="${STATICHOST_BUILDER:-https://builder.statichost.eu}"
46+
47+ # Create temporary zip file securely
48+ TEMP_ZIP="$(mktemp).zip"
49+ trap "rm -f $TEMP_ZIP" EXIT
50+
51+ echo "Zipping directory '$DIRECTORY'..."
52+ cd "$DIRECTORY"
53+ zip -qr "$TEMP_ZIP" .
4054
41- echo "Uploading directory '$DIRECTORY' to '$SITE_NAME'..."
42- # The shcli script automatically handles the zipping and uploading
43- ./shcli "$SITE_NAME" "$DIRECTORY"
55+ echo "Uploading to $BUILDER_HOST/$SITE_NAME/drop..."
56+ curl --fail-with-body \
57+ -X POST "$BUILDER_HOST/$SITE_NAME/drop" \
58+ -H "Authorization: Bearer $STATICHOST_APIKEY" \
59+ -H "Content-Type: application/zip" \
60+ -H "Accept: text/plain" \
61+ --data-binary "@$TEMP_ZIP"
4462
4563 echo ""
4664 echo "Upload complete!"
0 commit comments