diff --git a/.github/workflows/deploy-to-vps.yml b/.github/workflows/deploy-to-vps.yml index f722489..c019903 100644 --- a/.github/workflows/deploy-to-vps.yml +++ b/.github/workflows/deploy-to-vps.yml @@ -15,6 +15,8 @@ jobs: - name: Deploy to VPS uses: easingthemes/ssh-deploy@main + env: + VPS_ENV_DIRECTORY: ${{ secrets.VPS_ENV_DIRECTORY }} with: SSH_PRIVATE_KEY: ${{ secrets.VPS_SSH_PRIVATE_KEY }} ARGS: "-rlgoDzvc --delete" @@ -22,20 +24,20 @@ jobs: REMOTE_USER: ${{ secrets.VPS_USER }} TARGET: ${{ secrets.VPS_TARGET }} SCRIPT_AFTER: | - # Check if a directory for environment and config files is specified and copy its contents to the current directory if yes - if [ -n "${{ secrets.VPS_ENV_DIRECTORY }}" ] && [ -d "${{ secrets.VPS_ENV_DIRECTORY }}" ]; then cp -ar "${{ secrets.VPS_ENV_DIRECTORY }}"/. .; fi - + # Get environment and config files + cp -ar ${{ env.VPS_ENV_DIRECTORY }}/. . + # Detect all usable Compose files ([docker-]compose.yml and [docker-]compose.override.yml) and prefix their filename with "-f " COMPOSE=$( [ -f "docker-compose.yml" ] && echo -n "-f docker-compose.yml " || true; \ [ -f "docker-compose.override.yml" ] && echo -n "-f docker-compose.override.yml " || true; \ [ -f "compose.yml" ] && echo -n "-f compose.yml " || true; \ [ -f "compose.override.yml" ] && echo -n "-f compose.override.yml " || true ) - + # Stop, remove, and build the Docker Compose stack - docker compose $COMPOSE stop - docker compose $COMPOSE rm + docker compose $COMPOSE down -v --remove-orphans sleep 60 docker compose $COMPOSE build --no-cache docker compose $COMPOSE up -d docker image prune -af + SCRIPT_AFTER_REQUIRED: true