ci: compress deploy artifact to speed up ssh publish

This commit is contained in:
root
2026-03-10 00:34:20 +08:00
parent df4fc36819
commit be5a1bcdd1
2 changed files with 20 additions and 5 deletions
+7 -5
View File
@@ -13,7 +13,7 @@ concurrency:
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 30
steps:
- name: Checkout
@@ -31,6 +31,8 @@ jobs:
run: |
mkdir -p tmp
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o tmp/wx_service ./cmd/api
gzip -9 -c tmp/wx_service > tmp/wx_service.gz
ls -lh tmp/wx_service tmp/wx_service.gz
- name: Prepare SSH
env:
@@ -56,9 +58,9 @@ jobs:
USER: ${{ secrets.PROD_USER }}
run: |
set -e
REMOTE_BIN="/tmp/wx_service-${GITHUB_SHA}"
REMOTE_BIN_GZ="/tmp/wx_service-${GITHUB_SHA}.gz"
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=15 -o ServerAliveInterval=10 -o ServerAliveCountMax=3"
scp -O ${SSH_OPTS} -P "${PORT:-22}" tmp/wx_service "${USER:-root}@${HOST}:${REMOTE_BIN}"
scp -O ${SSH_OPTS} -P "${PORT:-22}" tmp/wx_service.gz "${USER:-root}@${HOST}:${REMOTE_BIN_GZ}"
- name: Deploy on server
env:
@@ -67,12 +69,12 @@ jobs:
USER: ${{ secrets.PROD_USER }}
run: |
set -e
REMOTE_BIN="/tmp/wx_service-${GITHUB_SHA}"
REMOTE_BIN_GZ="/tmp/wx_service-${GITHUB_SHA}.gz"
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=15 -o ServerAliveInterval=10 -o ServerAliveCountMax=3"
ssh ${SSH_OPTS} -p "${PORT:-22}" "${USER:-root}@${HOST}" \
"APP_DIR='/www/wwwroot/wx_service' \
DIST_DIR='/www/wwwroot/wx_service/dist' \
SOURCE_BIN='${REMOTE_BIN}' \
SOURCE_BIN='${REMOTE_BIN_GZ}' \
RELEASE_ID='${GITHUB_SHA}' \
SERVICE_NAME='wx_service' \
RUN_USER='www' \