-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
158 lines (139 loc) · 5.05 KB
/
action.yml
File metadata and controls
158 lines (139 loc) · 5.05 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Setup spiceio
description: Install a released version of spiceio and start the S3-to-SMB proxy
inputs:
version:
description: Release tag to install (e.g. "v0.1.0"). Use "latest" for the most recent release.
required: false
default: latest
smb-url:
description: >
SMB connection URL: smb://user:pass@server/share or smb://user:pass@server:port/share.
Password can also be provided separately via smb-pass.
required: true
smb-pass:
description: SMB password (overrides password in smb-url if both provided)
required: false
default: ""
bucket:
description: Virtual S3 bucket name
required: false
default: spiceio
region:
description: AWS region to advertise
required: false
default: us-east-1
bind:
description: Listen address for the S3 endpoint
required: false
default: "127.0.0.1:8333"
token:
description: GitHub token for downloading release assets from private repos
required: true
outputs:
endpoint:
description: The S3-compatible endpoint URL
value: ${{ steps.start.outputs.endpoint }}
pid:
description: PID of the spiceio process (use to stop it at the end of your workflow)
value: ${{ steps.start.outputs.pid }}
runs:
using: composite
steps:
- name: Download and install spiceio
id: install
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
set -euo pipefail
REPO="spiceai/spiceio"
INSTALL_DIR="${RUNNER_TEMP}/spiceio-bin"
ASSET="spiceio-${RUNNER_OS}-${RUNNER_ARCH}.tar.gz"
VERSION="${{ inputs.version }}"
mkdir -p "$INSTALL_DIR"
if [[ "$VERSION" == "latest" ]]; then
gh release download --repo "$REPO" --pattern "$ASSET" --pattern "${ASSET}.sha256" --dir "$INSTALL_DIR"
else
gh release download "$VERSION" --repo "$REPO" --pattern "$ASSET" --pattern "${ASSET}.sha256" --dir "$INSTALL_DIR"
fi
# Verify integrity
cd "$INSTALL_DIR"
shasum -a 256 -c "${ASSET}.sha256"
tar xzf "$ASSET" -C "$INSTALL_DIR"
chmod +x "$INSTALL_DIR/spiceio"
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
- name: Start spiceio
id: start
shell: bash
env:
SMB_URL: ${{ inputs.smb-url }}
SMB_PASS_OVERRIDE: ${{ inputs.smb-pass }}
SPICEIO_BUCKET: ${{ inputs.bucket }}
SPICEIO_REGION: ${{ inputs.region }}
SPICEIO_BIND: ${{ inputs.bind }}
run: |
set -euo pipefail
# Parse smb://user:pass@server:port/share
# Strips the smb:// prefix, then splits on :, @, /
URL="${SMB_URL#smb://}"
USERINFO="${URL%%@*}"
HOSTPATH="${URL#*@}"
SPICEIO_SMB_USER="${USERINFO%%:*}"
# Extract password from URL only if user:pass@ format is used
if [[ "$USERINFO" == *:* ]]; then
URL_PASS="${USERINFO#*:}"
else
URL_PASS=""
fi
# smb-pass input takes priority, then URL password
if [[ -n "$SMB_PASS_OVERRIDE" ]]; then
SPICEIO_SMB_PASS="$SMB_PASS_OVERRIDE"
elif [[ -n "$URL_PASS" ]]; then
SPICEIO_SMB_PASS="$URL_PASS"
else
echo "::error::No SMB password provided (use smb-pass input or include in smb-url)"
exit 1
fi
HOSTPORT="${HOSTPATH%%/*}"
SPICEIO_SMB_SHARE="${HOSTPATH#*/}"
if [[ "$HOSTPORT" == *:* ]]; then
SPICEIO_SMB_SERVER="${HOSTPORT%%:*}"
SPICEIO_SMB_PORT="${HOSTPORT#*:}"
else
SPICEIO_SMB_SERVER="$HOSTPORT"
SPICEIO_SMB_PORT="445"
fi
export SPICEIO_SMB_SERVER SPICEIO_SMB_PORT SPICEIO_SMB_USER SPICEIO_SMB_PASS SPICEIO_SMB_SHARE
export SPICEIO_BUCKET SPICEIO_REGION SPICEIO_BIND
SPICEIO_LOG="${RUNNER_TEMP}/spiceio.log"
: > "$SPICEIO_LOG"
export SPICEIO_LOG_FILE="$SPICEIO_LOG"
spiceio &
PID=$!
# Wait for spiceio to report its actual listening address (port may
# auto-increment if the requested port was busy).
echo "Waiting for spiceio on ${SPICEIO_BIND}..."
ENDPOINT=""
for i in $(seq 1 60); do
if ! kill -0 "$PID" 2>/dev/null; then
echo "::error::spiceio exited unexpectedly"
echo "::group::spiceio log"
cat "$SPICEIO_LOG" 2>/dev/null || echo "(log file missing)"
echo "::endgroup::"
exit 1
fi
ENDPOINT=$(grep 'listening on' "$SPICEIO_LOG" 2>/dev/null | grep -o 'http://[^ ]*' | tail -1 || true)
if [[ -n "$ENDPOINT" ]] && curl -fsS -o /dev/null "$ENDPOINT/" 2>/dev/null; then
echo "spiceio ready at $ENDPOINT (PID $PID)"
echo "endpoint=$ENDPOINT" >> "$GITHUB_OUTPUT"
echo "pid=$PID" >> "$GITHUB_OUTPUT"
exit 0
fi
sleep 1
done
echo "::error::spiceio failed to start within 60s"
echo "::group::spiceio log"
cat "$SPICEIO_LOG" 2>/dev/null || echo "(log file missing)"
echo "::endgroup::"
kill "$PID" 2>/dev/null || true
exit 1