@@ -27,11 +27,18 @@ jobs:
27
27
username : ${{ secrets.BROADCASTER_SSH_USERNAME }}
28
28
key : ${{ secrets.BROADCASTER_SSH_PRIV_KEY }}
29
29
script : |
30
+ # Exit if any command fails.
31
+ set -e
32
+
30
33
export APP_NAME=broadcaster
31
34
export TAG=${{ github.ref_name }}
32
35
export TAG=${TAG#*-v}
36
+
37
+ echo "Cleaning previous broadcaster docker image"
33
38
docker stop $APP_NAME
34
39
docker rm $APP_NAME
40
+
41
+ echo "Running a new broadcaster image - $TAG"
35
42
docker run -d --restart unless-stopped \
36
43
--name $APP_NAME \
37
44
-e SECRET_KEY_BASE=${{ secrets.BROADCASTER_SECRET_KEY_BASE }} \
@@ -42,10 +49,40 @@ jobs:
42
49
-e WHIP_TOKEN=${{ secrets.BROADCASTER_WHIP_TOKEN }} \
43
50
--network host \
44
51
ghcr.io/elixir-webrtc/apps/$APP_NAME:$TAG
45
- docker image prune --all --force
46
-
47
-
48
52
53
+ docker image prune --all --force
49
54
55
+ echo "Waiting for broadcaster to be ready."
56
+ attempts=10
57
+ until curl localhost:4000 > /dev/null 2>&1
58
+ do
59
+ ((attempts--))
60
+ if [ $attempts -eq 0 ]; then
61
+ exit 1
62
+ fi
63
+ sleep 1
64
+ done
65
+
66
+ echo "Cloning client script"
67
+ rm -rf /tmp/apps
68
+ git clone -b ${{ github.ref_name }} https://github.com/${{ github.repository }} /tmp/apps
69
+ cd /tmp/apps/broadcaster
50
70
71
+ echo "Terminating previously running client"
72
+ # ignore non-zero exit status
73
+ killall node || true
74
+
75
+ # This is needed to find `node` and `npm` commands.
76
+ # See difference between interactive and non-interactive shells.
77
+ source ~/.nvm/nvm.sh
78
+
79
+ echo "Installing puppeteer in current directory"
80
+ npm install puppeteer
51
81
82
+ # Run node in bg, disconnect it from terminal and redirect all output.
83
+ # In other case action won't end.
84
+ echo "Running client script"
85
+ USERNAME=${{ secrets.BROADCASTER_ADMIN_USERNAME }} \
86
+ PASSWORD=${{ secrets.BROADCASTER_ADMIN_PASSWORD }} \
87
+ TOKEN=${{ secrets.BROADCASTER_WHIP_TOKEN }} \
88
+ nohup node headless_client.js > nohup.out 2> nohup.err < /dev/null &
0 commit comments