Fix CI workflow - add git config for botserver update
Some checks failed
BotServer CI/CD / build (push) Failing after 1s
Some checks failed
BotServer CI/CD / build (push) Failing after 1s
This commit is contained in:
parent
c6d2f19458
commit
4785f8b1d7
1 changed files with 18 additions and 34 deletions
|
|
@ -33,7 +33,6 @@ jobs:
|
||||||
|
|
||||||
- name: Setup Workspace
|
- name: Setup Workspace
|
||||||
run: |
|
run: |
|
||||||
# Use /tmp for workspace (runner has full permissions)
|
|
||||||
mkdir -p /tmp/sccache
|
mkdir -p /tmp/sccache
|
||||||
mkdir -p /tmp/cargo
|
mkdir -p /tmp/cargo
|
||||||
mkdir -p /tmp/persistent-botserver
|
mkdir -p /tmp/persistent-botserver
|
||||||
|
|
@ -45,14 +44,12 @@ jobs:
|
||||||
git config --global --add safe.directory "*"
|
git config --global --add safe.directory "*"
|
||||||
git config --global user.email "ci@pragmatismo.com.br"
|
git config --global user.email "ci@pragmatismo.com.br"
|
||||||
git config --global user.name "CI Runner"
|
git config --global user.name "CI Runner"
|
||||||
git config --global pull.rebase false
|
|
||||||
|
|
||||||
- name: Update Repositories
|
- name: Update Repositories
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
cd /tmp/persistent-botserver
|
cd /tmp/persistent-botserver
|
||||||
|
|
||||||
# Update botlib
|
|
||||||
if [ -d botlib/.git ]; then
|
if [ -d botlib/.git ]; then
|
||||||
echo "Updating botlib..."
|
echo "Updating botlib..."
|
||||||
(cd botlib && git pull origin main)
|
(cd botlib && git pull origin main)
|
||||||
|
|
@ -61,23 +58,20 @@ jobs:
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update botserver
|
|
||||||
if [ -d botserver/.git ]; then
|
if [ -d botserver/.git ]; then
|
||||||
echo "Updating botserver..."
|
echo "Updating botserver..."
|
||||||
(cd botserver && git pull origin main)
|
(cd botserver && git config user.email "ci@pragmatismo.com.br" && git config user.name "CI Runner" && git pull origin main)
|
||||||
else
|
else
|
||||||
echo "Cloning botserver..."
|
echo "Cloning botserver..."
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update gb workspace
|
|
||||||
if [ -d /tmp/gb-ws/.git ]; then
|
if [ -d /tmp/gb-ws/.git ]; then
|
||||||
(cd /tmp/gb-ws && git pull origin main)
|
(cd /tmp/gb-ws && git pull origin main)
|
||||||
else
|
else
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /tmp/gb-ws
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /tmp/gb-ws
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy Cargo.toml
|
|
||||||
cp /tmp/gb-ws/Cargo.toml Cargo.toml
|
cp /tmp/gb-ws/Cargo.toml Cargo.toml
|
||||||
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do
|
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do
|
||||||
grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml
|
grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml
|
||||||
|
|
@ -88,30 +82,20 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
export PATH="/home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
|
export PATH="/home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
|
||||||
sccache --start-server 2>/dev/null || true
|
sccache --start-server 2>/dev/null || true
|
||||||
echo "Building BotServer..."
|
|
||||||
cargo build --package botserver 2>&1 | tee /tmp/build.log
|
cargo build --package botserver 2>&1 | tee /tmp/build.log
|
||||||
sccache --stop-server 2>/dev/null || true
|
sccache --stop-server 2>/dev/null || true
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
run: |
|
run: |
|
||||||
set -e
|
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
||||||
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5"
|
|
||||||
|
|
||||||
echo "Stopping botserver..."
|
|
||||||
ssh $SSH_ARGS system "sudo systemctl stop botserver 2>/dev/null || true; sleep 2"
|
ssh $SSH_ARGS system "sudo systemctl stop botserver 2>/dev/null || true; sleep 2"
|
||||||
|
scp $SSH_ARGS /tmp/persistent-botserver/target/debug/botserver system:/opt/gbo/bin/botserver
|
||||||
echo "Deploying binary..."
|
ssh $SSH_ARGS system "sudo chmod +x /opt/gbo/bin/botserver && sudo chown gbuser:gbuser /opt/gbo/bin/botserver"
|
||||||
scp $SSH_ARGS /tmp/persistent-botserver/target/debug/botserver system:/tmp/botserver-new
|
ssh $SSH_ARGS system "sudo systemctl start botserver"
|
||||||
ssh $SSH_ARGS system "sudo mv /tmp/botserver-new /opt/gbo/bin/botserver && sudo chmod +x /opt/gbo/bin/botserver && sudo chown gbuser:gbuser /opt/gbo/bin/botserver"
|
|
||||||
|
|
||||||
echo "Starting botserver..."
|
|
||||||
ssh $SSH_ARGS system "sudo systemctl daemon-reload && sudo systemctl start botserver"
|
|
||||||
|
|
||||||
echo "Health check..."
|
|
||||||
sleep 5
|
sleep 5
|
||||||
for i in $(seq 1 30); do
|
for i in $(seq 1 30); do
|
||||||
if ssh $SSH_ARGS system "curl -sf http://localhost:8080/health" 2>/dev/null; then
|
if ssh $SSH_ARGS system "curl -sf http://localhost:8080/api/health" 2>/dev/null; then
|
||||||
echo "Health check passed!"
|
echo "Health check passed!"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
@ -122,4 +106,4 @@ jobs:
|
||||||
- name: Verify
|
- name: Verify
|
||||||
run: |
|
run: |
|
||||||
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
||||||
ssh $SSH_ARGS system "pgrep -f botserver >/dev/null && echo OK || echo FAIL"
|
ssh $SSH_ARGS system "pgrep -f botserver && echo 'OK: botserver running' || echo 'FAIL'"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue