cloud-game/.github/workflows/redeploy/redeploy_specific.sh
giongto35 4935997c82
CD Flow to redeploy after push (#320)
* Add redeploy.sh to redeploy

* Add redeploy to workflow

* Update redeploy script

* Redeploy script

* Test

* run after checkout

* Update path

* checkout ssh

* Update build

* remove unnecesary

* Update placeholder

* Update domain

* Retrigger

* Update docker login

* Update config

* deploy with config

* Update sync config

* Redeploy

* Update redeploy.sh

* Redeploy specific

* redeploy.sh

* redeploy specific.sh

* add more server

* Update redeploy

* Update docker publish

* Redeploy

* Update port

* Update redeploy.sh

* test build

* Remove test with build.yaml

* Clean up

* Clean up
2021-05-28 03:51:25 +08:00

34 lines
1.4 KiB
Bash
Executable file
Vendored

#! /bin/bash
iplist=$1
for ip_address in $iplist
do
echo $ip_address
ssh-keyscan -H $ip_address >> ~/.ssh/known_hosts
sleep 2
if [ "$ip_address" == "167.172.70.98" ] || [ "$ip_address" == "cloudretro.io" ]
then
launchcommand="coordinator > /tmp/startup.log"
else
launchcommand="Xvfb :99 & worker --coordinatorhost cloudretro.io --zone \$zone > /tmp/startup.log"
fi
ssh root@$ip_address "mkdir -p /cloud-game/configs"
rsync ./.github/workflows/redeploy/config.yaml root@$ip_address:/cloud-game/configs/config.yaml
run_content="'#! /bin/bash
echo $PASSWORD | docker login https://docker.pkg.github.com --username $USERNAME --password-stdin;
ufw disable;
docker system prune -f;
source /etc/profile;
docker pull docker.pkg.github.com/giongto35/cloud-game/cloud-game:latest;
docker rm cloud-game -f;
docker run --privileged -d --network=host --env DISPLAY=:99 --env MESA_GL_VERSION_OVERRIDE=3.3 -v cores:/usr/local/share/cloud-game/assets/cores -v /cloud-game/configs:/usr/local/share/cloud-game/configs -v /cloud-game/games:/usr/local/share/cloud-game/assets/games -v /cloud-game/cache:/usr/local/share/cloud-game/assets/cache --name cloud-game docker.pkg.github.com/giongto35/cloud-game/cloud-game bash -c \"$launchcommand\"'"
ssh root@$ip_address "echo $run_content > ~/run.sh"
ssh root@$ip_address "chmod +x run.sh; ./run.sh"
done
echo 'done'