fix(ci): reuse SSH connection and delay service restart
CI / Test and publish (push) Successful in 21s
CI / Deploy published image to production (push) Successful in 16s

This commit is contained in:
Valentin Popov committed 2026-10-15 03:39:40 +04:00
1 parent 7663ef111f
commit 69ca30ae6b
1 file changed
+12 -11
+12 -11
View File
@@ -156,16 +156,14 @@ jobs:
IdentitiesOnly yes IdentitiesOnly yes
BatchMode yes BatchMode yes
ConnectTimeout 15 ConnectTimeout 15
ConnectionAttempts 3
ControlMaster auto
ControlPath $HOME/.ssh/vacationplanner-deploy_socket
ControlPersist 10m
ServerAliveInterval 15
ServerAliveCountMax 3
EOF EOF
ssh -F "$HOME/.ssh/vacationplanner-deploy_config" -MNf vacationplanner-deploy
- name: Stop service
shell: bash
run: |
ssh -F "$HOME/.ssh/vacationplanner-deploy_config" vacationplanner-deploy "
set -e
cd '$DEPLOY_PATH'
docker compose stop app
"
- name: Upload Compose file - name: Upload Compose file
shell: bash shell: bash
@@ -198,12 +196,13 @@ jobs:
printf '\\nIMAGE=%s\\n' '$IMAGE' >> .env printf '\\nIMAGE=%s\\n' '$IMAGE' >> .env
" "
- name: Start service - name: Restart service
shell: bash shell: bash
run: | run: |
ssh -F "$HOME/.ssh/vacationplanner-deploy_config" vacationplanner-deploy " ssh -F "$HOME/.ssh/vacationplanner-deploy_config" vacationplanner-deploy "
set -e set -e
cd '$DEPLOY_PATH' cd '$DEPLOY_PATH'
docker compose stop app
docker compose up --pull never --detach --force-recreate app docker compose up --pull never --detach --force-recreate app
" "
@@ -223,6 +222,8 @@ jobs:
if: always() if: always()
shell: bash shell: bash
run: | run: |
ssh -F "$HOME/.ssh/vacationplanner-deploy_config" -O exit vacationplanner-deploy 2>/dev/null || true
rm -f -- "$HOME/.ssh/vacationplanner-deploy" \ rm -f -- "$HOME/.ssh/vacationplanner-deploy" \
"$HOME/.ssh/vacationplanner-deploy_known_hosts" \ "$HOME/.ssh/vacationplanner-deploy_known_hosts" \
"$HOME/.ssh/vacationplanner-deploy_config" "$HOME/.ssh/vacationplanner-deploy_config" \
"$HOME/.ssh/vacationplanner-deploy_socket"