From a45b318d5e9573c01adfcf4f4dbcc351265a2ac0 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 4 Jul 2026 14:21:00 -0400 Subject: [PATCH] build fix7 --- .gitea/workflows/build-and-deploy.yml | 29 ++++++++++++++++++--------- docs/DOCKER.md | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index 90f2a2b..07c334b 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -15,6 +15,7 @@ env: GIT_SSL_NO_VERIFY: "true" REGISTRY_HOST: 192.168.3.80 DEPLOY_REGISTRY_HOST: 10.0.0.4 + DEPLOY_SSH_HOST: 10.0.0.1 DOCKERFILE_PATH: Dockerfile.production DOCKER_PLATFORM: linux/amd64 DEPLOY_ROOT: /opt/rentaldrivego @@ -126,13 +127,14 @@ jobs: VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }} VPS_SSH_KEY_B64: ${{ secrets.VPS_SSH_KEY_B64 }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_SSH_KEY" ] && [ -z "$VPS_SSH_KEY_B64" ]; then echo "::error::VPS_SSH_KEY_B64 or VPS_SSH_KEY is required to build on the remote Docker host" exit 1 fi if [ -z "$VPS_HOST" ] || \ [ -z "${{ secrets.VPS_USER }}" ]; then - echo "::error::VPS_USER and VPS_IP secrets are required to build on the remote Docker host" + echo "::error::VPS_USER and either VPS_IP or DEPLOY_SSH_HOST are required to build on the remote Docker host" exit 1 fi @@ -149,8 +151,9 @@ jobs: VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }} VPS_SSH_KEY_B64: ${{ secrets.VPS_SSH_KEY_B64 }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi echo "Using SSH host $VPS_HOST" @@ -193,8 +196,9 @@ jobs: env: VPS_HOST: ${{ secrets.VPS_IP }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi SSH_OPTIONS="-i $HOME/.ssh/id_rsa -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=$HOME/.ssh/known_hosts" @@ -210,8 +214,9 @@ jobs: REMOTE_BUILD_DIR: ${{ env.DEPLOY_ROOT }}/build-context VPS_HOST: ${{ secrets.VPS_IP }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi SSH_OPTIONS="-i $HOME/.ssh/id_rsa -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=$HOME/.ssh/known_hosts" @@ -242,8 +247,9 @@ jobs: REMOTE_BUILD_DIR: ${{ env.DEPLOY_ROOT }}/build-context VPS_HOST: ${{ secrets.VPS_IP }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi SSH_OPTIONS="-i $HOME/.ssh/id_rsa -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=$HOME/.ssh/known_hosts" @@ -336,6 +342,7 @@ jobs: VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }} VPS_SSH_KEY_B64: ${{ secrets.VPS_SSH_KEY_B64 }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if { [ -z "$VPS_SSH_KEY" ] && [ -z "$VPS_SSH_KEY_B64" ]; } || \ [ -z "$VPS_HOST" ] || \ [ -z "${{ secrets.VPS_USER }}" ]; then @@ -360,8 +367,9 @@ jobs: VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }} VPS_SSH_KEY_B64: ${{ secrets.VPS_SSH_KEY_B64 }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi echo "Using SSH host $VPS_HOST" @@ -405,8 +413,9 @@ jobs: env: VPS_HOST: ${{ secrets.VPS_IP }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi SSH_OPTIONS="-i $HOME/.ssh/id_rsa -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=$HOME/.ssh/known_hosts" @@ -422,8 +431,9 @@ jobs: env: VPS_HOST: ${{ secrets.VPS_IP }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi SSH_OPTIONS="-i $HOME/.ssh/id_rsa -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=$HOME/.ssh/known_hosts" @@ -448,8 +458,9 @@ jobs: env: VPS_HOST: ${{ secrets.VPS_IP }} run: | + VPS_HOST="${VPS_HOST:-$DEPLOY_SSH_HOST}" if [ -z "$VPS_HOST" ]; then - echo "::error::VPS_IP secret is required" + echo "::error::VPS_IP secret or DEPLOY_SSH_HOST is required" exit 1 fi SSH_OPTIONS="-i $HOME/.ssh/id_rsa -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=$HOME/.ssh/known_hosts" diff --git a/docs/DOCKER.md b/docs/DOCKER.md index 6155893..b02c22d 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -219,7 +219,7 @@ VPS_USER= VPS_SSH_KEY= ``` -`VPS_IP` is required. The workflow does not fall back to a hard-coded SSH host, so a missing secret fails before any SSH attempt. +`VPS_IP` overrides the workflow's default `DEPLOY_SSH_HOST`. If `VPS_IP` is not set, the workflow uses `DEPLOY_SSH_HOST` from `.gitea/workflows/build-and-deploy.yml`. `VPS_SSH_KEY` must be an unencrypted private key that OpenSSH can read in a non-interactive job. The workflow also accepts `VPS_SSH_KEY_B64` when you prefer storing a base64-encoded private key as a single line.