Skip to content

Commit 66362dc

Browse files
committed
Update deploy.yml
1 parent 13cb31e commit 66362dc

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ jobs:
145145
id: targetdir
146146
run: |
147147
set -euo pipefail
148-
# Nếu repo secret rỗng -> mặc định "~"
149-
if [ -z "${DEPLOY_DIR_SECRET:-}" ]; then
150-
echo "TARGET_ROOT=~" >> "$GITHUB_OUTPUT"
148+
if [ -n "${DEPLOY_DIR_SECRET:-}" ]; then
149+
echo "DEPLOY_DIR_FINAL=${DEPLOY_DIR_SECRET%/}" >> "$GITHUB_OUTPUT"
151150
else
152-
echo "TARGET_ROOT=${DEPLOY_DIR_SECRET%/}" >> "$GITHUB_OUTPUT"
151+
# Mặc định
152+
echo "DEPLOY_DIR_FINAL=~/codecampus" >> "$GITHUB_OUTPUT"
153153
fi
154154
155155
- name: Upload bundle to server
@@ -160,16 +160,15 @@ jobs:
160160
key: ${{ secrets.SSH_PRIVATE_KEY }}
161161
port: ${{ secrets.SSH_PORT }}
162162
source: "deploy_bundle/*"
163-
target: "${{ steps.targetdir.outputs.TARGET_ROOT }}/codecampus"
163+
target: "${{ steps.targetdir.outputs.DEPLOY_DIR_FINAL }}"
164164
overwrite: true
165-
strip_components: 1
166165

167166
- name: Verify .env identical & run deploy
168167
uses: appleboy/[email protected]
169168
env:
170169
IMAGE_TAG: ${{ env.IMAGE_TAG }}
171170
ENV_SHA: ${{ env.ENV_SHA }}
172-
DEPLOY_DIR: ${{ secrets.DEPLOY_DIR }}
171+
DEPLOY_DIR: ${{ steps.targetdir.outputs.DEPLOY_DIR_FINAL }}
173172
with:
174173
host: ${{ secrets.SSH_HOST }}
175174
username: ${{ secrets.SSH_USER }}
@@ -178,8 +177,7 @@ jobs:
178177
script_stop: true
179178
script: |
180179
set -euo pipefail
181-
ROOT="${DEPLOY_DIR:-$HOME}"
182-
DEPLOY_DIR="${ROOT%/}/codecampus"
180+
DEPLOY_DIR="${DEPLOY_DIR:-$HOME/codecampus}"
183181
mkdir -p "$DEPLOY_DIR"
184182
cd "$DEPLOY_DIR"
185183
@@ -195,4 +193,4 @@ jobs:
195193
exit 1
196194
fi
197195
198-
IMAGE_TAG="${IMAGE_TAG:-latest}" DEPLOY_DIR="$ROOT" bash ./deploy.sh
196+
IMAGE_TAG="${IMAGE_TAG:-latest}" DEPLOY_DIR="$DEPLOY_DIR" bash ./deploy.sh

0 commit comments

Comments
 (0)