Skip to content

Workflow file for this run

name: Continuous Deployment
on:
workflow_dispatch:
push:
branches:
- production
paths-ignore:
- .gitignore
- README.md
- start-database.sh
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: executing deploy via ssh
uses: appleboy/[email protected]
with:
host: ${{secrets.HOST}}
username: ${{secrets.USERNAME}}
password: ${{secrets.PASS}}
command_timeout: 540s
script: |
UNSTAGGED_IMAGE_ID=$(docker images --filter=reference=site-struct-2024-web:latest --format "{{.ID}}")
cd docker_compose_struct/
git pull
cd site-struct-2024/
execute_with_retry() {
local retries=$1
local command=$2
while [ $retries -gt 0 ]; do
if $command; then
echo "$command successful!"
return 0
else
echo "$command failed, retrying..."
((retries--))
fi
done
echo "$command failed after all retries"
exit 1
}
execute_with_retry 2 "docker compose build web"
execute_with_retry 2 "docker compose up -d"
docker rmi $UNSTAGGED_IMAGE_ID