-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
142 lines (132 loc) · 4.32 KB
/
action.yml
File metadata and controls
142 lines (132 loc) · 4.32 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
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-server:
description: SMB server hostname or IP
required: true
smb-user:
description: SMB username
required: true
smb-pass:
description: SMB password
required: true
smb-share:
description: SMB share name
required: true
smb-port:
description: SMB port
required: false
default: "445"
smb-domain:
description: SMB domain
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 background process (empty if skipped)
value: ${{ steps.start.outputs.pid }}
runs:
using: composite
steps:
- name: Download spiceio release
uses: robinraju/release-downloader@v1
with:
repository: spiceai/spiceio
tag: ${{ inputs.version }}
latest: ${{ inputs.version == 'latest' }}
fileName: spiceio-${{ runner.os }}-${{ runner.arch }}.tar.gz
out-file-path: ${{ runner.temp }}/spiceio-dl
token: ${{ inputs.token }}
- name: Install spiceio
id: install
shell: bash
run: |
set -euo pipefail
INSTALL_DIR="${RUNNER_TEMP}/spiceio-bin"
mkdir -p "$INSTALL_DIR"
tar xzf "${RUNNER_TEMP}/spiceio-dl/spiceio-${{ runner.os }}-${{ runner.arch }}.tar.gz" -C "$INSTALL_DIR"
chmod +x "$INSTALL_DIR/spiceio"
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
echo "pid_file=${RUNNER_TEMP}/spiceio.pid" >> "$GITHUB_OUTPUT"
- name: Start spiceio
id: start
shell: bash
env:
SPICEIO_SMB_SERVER: ${{ inputs.smb-server }}
SPICEIO_SMB_PORT: ${{ inputs.smb-port }}
SPICEIO_SMB_USER: ${{ inputs.smb-user }}
SPICEIO_SMB_PASS: ${{ inputs.smb-pass }}
SPICEIO_SMB_DOMAIN: ${{ inputs.smb-domain }}
SPICEIO_SMB_SHARE: ${{ inputs.smb-share }}
SPICEIO_BUCKET: ${{ inputs.bucket }}
SPICEIO_REGION: ${{ inputs.region }}
SPICEIO_BIND: ${{ inputs.bind }}
run: |
set -euo pipefail
ENDPOINT="http://${SPICEIO_BIND}"
PID_FILE="${{ steps.install.outputs.pid_file }}"
# Skip if spiceio is already listening on the requested address
if curl -sf -o /dev/null "$ENDPOINT/" 2>/dev/null; then
echo "spiceio already running at $ENDPOINT — skipping start"
echo "endpoint=$ENDPOINT" >> "$GITHUB_OUTPUT"
echo "pid=" >> "$GITHUB_OUTPUT"
echo "skipped=true" >> "$GITHUB_OUTPUT"
exit 0
fi
spiceio &
PID=$!
echo "$PID" > "$PID_FILE"
echo "pid=$PID" >> "$GITHUB_OUTPUT"
echo "endpoint=$ENDPOINT" >> "$GITHUB_OUTPUT"
echo "skipped=false" >> "$GITHUB_OUTPUT"
# Wait for readiness
echo "Waiting for spiceio on ${SPICEIO_BIND}..."
for i in $(seq 1 30); do
if curl -sf -o /dev/null "$ENDPOINT/" 2>/dev/null; then
echo "spiceio ready at $ENDPOINT (PID $PID)"
exit 0
fi
if ! kill -0 "$PID" 2>/dev/null; then
echo "::error::spiceio exited unexpectedly"
exit 1
fi
sleep 1
done
echo "::error::spiceio failed to start within 30s"
exit 1
- name: Register cleanup
if: always() && steps.start.outputs.skipped != 'true'
shell: bash
run: |
PID_FILE="${{ steps.install.outputs.pid_file }}"
if [[ -f "$PID_FILE" ]]; then
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
echo "Stopping spiceio (PID $PID)"
kill "$PID" 2>/dev/null || true
wait "$PID" 2>/dev/null || true
fi
rm -f "$PID_FILE"
fi