Skip to content

Commit 4b1d65f

Browse files
feat: refactor
1 parent f87b588 commit 4b1d65f

3 files changed

Lines changed: 39 additions & 12 deletions

File tree

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: "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"
33
branding:
44
icon: "upload-cloud"
55
color: "blue"
66

77
inputs:
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!"

.github/workflows/houtwerk.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ jobs:
2323
api-token: ${{ secrets.STATICHOST_API_KEY }}
2424
site-name: "houtwerk"
2525
# Astro outputs the built site to the 'dist' folder by default
26-
path: "bun/houtwerk.hering.services/dist"
26+
path: "bun/houtwerk.hering.services/dist/"
27+
28+
# Add this right after your Upload to statichost.eu step
29+
- name: Upload Artifact for Debugging
30+
uses: actions/upload-artifact@v7
31+
with:
32+
name: built-site-zip
33+
# We need to temporarily tell our script not to delete the zip,
34+
# or we just upload the raw dist folder to look at the files!
35+
path: bun/houtwerk.hering.services/dist/

bun/houtwerk.hering.services/statichost.yml

Whitespace-only changes.

0 commit comments

Comments
 (0)