Skip to content

Commit f9700b5

Browse files
committed
Runner
1 parent 33ad1c0 commit f9700b5

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

.github/workflows/build-web.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@ jobs:
3030
username: ci
3131
privateKey: ${{ secrets.CI_SSH_KEY }}
3232

33+
- name: Copy runner wrapper file to remote server
34+
uses: garygrossgarten/[email protected]
35+
with:
36+
local: website/scripts/runner.sh
37+
remote: /var/www/core-js/runner.sh
38+
host: ${{ secrets.REMOTE_HOST }}
39+
username: ci
40+
privateKey: ${{ secrets.CI_SSH_KEY }}
41+
42+
- name: Make runner.sh executable on remote
43+
run: |
44+
ssh -o StrictHostKeyChecking=no ci@host "chmod +x /var/www/core-js/runner.sh"
45+
3346
- name: Setup SSH
3447
uses: webfactory/[email protected]
3548
with:
3649
ssh-private-key: ${{ secrets.CI_SSH_KEY }}
3750

3851
- name: Run node runner.mjs on remote server
3952
run: |
40-
ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "cd /var/www/core-js/ && node runner.mjs"
53+
ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "cd /var/www/core-js/ && ./runner.sh"

website/scripts/runner.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
LOCK_FILE=./runner.lock
3+
PID_FILE=./runner.pid
4+
5+
lock_acquired=false
6+
7+
for i in {1..60}; do
8+
if ln -s "$$" "$LOCK_FILE" 2>/dev/null; then
9+
lock_acquired=true
10+
break
11+
else
12+
echo "Another process running, waiting..."
13+
sleep 5
14+
fi
15+
done
16+
17+
if ! $lock_acquired; then
18+
echo "Timeout waiting for lock! Exiting."
19+
exit 1
20+
fi
21+
22+
echo "$$" > "$PID_FILE"
23+
24+
cleanup() {
25+
echo "Cleaning up..."
26+
rm -f "$LOCK_FILE" "$PID_FILE"
27+
}
28+
trap cleanup EXIT
29+
30+
node ./runner.mjs
31+
EXIT_CODE=$?
32+
33+
exit $EXIT_CODE

0 commit comments

Comments
 (0)