-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
68 lines (62 loc) · 2.3 KB
/
action.yml
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
name: "Svix Proxy"
description: "Use Svix proxy to tunnel publicly accessible URL to action runner port"
branding:
icon: "activity"
color: "gray-dark"
inputs:
port:
description: "Local port to proxy traffic to"
required: true
path:
description: "Specify an HTTP path on the local service"
required: false
default: /
logging:
description: "Enable postback logs (logs a URL you can visit to view requests proxied)"
required: false
default: false
outputs:
postback_url:
description: "URL the proxy is publicly available on"
value: ${{ steps.proxy.outputs.postback_url }}
runs:
using: "composite"
steps:
- run: wget https://github.com/svix/svix-cli/releases/download/v0.19.0/svix_0.19.0_linux_amd64.deb
shell: bash
- run: sudo dpkg -i svix_0.19.0_linux_amd64.deb
shell: bash
- run: sudo apt-get update && sudo apt-get install colorized-logs # this is to strip ansi chars from svix stdout
shell: bash
- name: Start Svix proxy
id: proxy
shell: bash
run: |
# Start the svix command in the background so once this step finishes, svix will still be running in the action runner instance for the next step to use the callback_url output
LOG_FILE="/tmp/svix.log"
touch $LOG_FILE
if [ "${{ inputs.logging }}" = true ]; then
svix listen http://localhost:${{ inputs.port }}${{ inputs.path }} >"$LOG_FILE" &
else
svix listen http://localhost:${{ inputs.port }}${{ inputs.path }} --no-logging >"$LOG_FILE" &
fi
# Watch Svix logs for 15 seconds
timeout=15
SECONDS=0
# Check logs until timeout
echo "Waiting for proxy postback URL..."
while [ $SECONDS -lt $timeout ]; do
# return true in grep so that it doesn't return 1 and close the script when no match is found
postback_url=$(ansi2txt <"$LOG_FILE"| grep "https://play.svix.com/in/" || true)
if [ -n "$postback_url" ]; then
# Found postback URL
echo "postback_url=$postback_url" >>"$GITHUB_OUTPUT"
# echo the CLI stdout
ansi2txt <"$LOG_FILE"
exit 0
fi
sleep 1
echo "Waiting for proxy postback URL..."
done
echo "Timeout reached, no postback URL found"
exit 1