45 lines
799 B
Bash
Executable File
45 lines
799 B
Bash
Executable File
#!/bin/bash
|
|
deploydir=$DEPLOYERDIR/$REPO/$BRANCH
|
|
|
|
mkdir -p $deploydir/src
|
|
cd $deploydir
|
|
|
|
git clone \
|
|
-b $BRANCH \
|
|
"http://deployer:$(cat /home/drm/deployer/token)@localhost:3000/$USER/$REPO" \
|
|
./src
|
|
|
|
cd src
|
|
git fetch origin $BRANCH
|
|
git reset --hard origin/$BRANCH
|
|
git checkout $COMMIT_HASH
|
|
|
|
make build
|
|
|
|
cd ..
|
|
echo "
|
|
[Unit]
|
|
Description=Deployment of $REPO/$BRANCH
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
ExecStart=make deploy
|
|
User=drm
|
|
WorkingDirectory=$deploydir/src
|
|
Restart=on-failure
|
|
StandardOutput=file:$deploydir/server.log
|
|
StandardError=file:$deploydir/server.log
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
" > deploy.service
|
|
|
|
service="deployer-$REPO-$BRANCH.service"
|
|
ln -sf $deploydir/deploy.service /etc/systemd/system/$service
|
|
|
|
systemctl daemon-reload
|
|
systemctl restart $service
|
|
|
|
|