Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a5bb1ab43 | |||
| bf47e69fa4 | |||
| b947bf7569 | |||
| f110bc6f16 | |||
| 0c9375ff32 | |||
| ef344e9ffc | |||
| 0d4904433e | |||
| 708662394f | |||
| 9b034764ad | |||
| 8748b43070 | |||
| d213a055a1 | |||
| 2371860f82 | |||
| dbd956fc6e | |||
| 1d59ee5336 |
@@ -192,6 +192,7 @@ jobs:
|
|||||||
frontend-lint:
|
frontend-lint:
|
||||||
name: Frontend Lint
|
name: Frontend Lint
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
timeout-minutes: 20
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -217,7 +218,17 @@ jobs:
|
|||||||
tar -xzf /tmp/repo.tar.gz --strip-components=1 -C .
|
tar -xzf /tmp/repo.tar.gz --strip-components=1 -C .
|
||||||
rm -f /tmp/repo.tar.gz
|
rm -f /tmp/repo.tar.gz
|
||||||
|
|
||||||
|
- name: Cache node_modules
|
||||||
|
id: cache-node-modules
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: apps/web/node_modules
|
||||||
|
key: ${{ runner.os }}-node-web-${{ hashFiles('apps/web/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-web-
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
name: Test SSH Secret
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [develop]
|
|
||||||
paths:
|
|
||||||
- '.gitea/workflows/test-ssh-secret.yml'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-ssh:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- name: Install SSH client
|
|
||||||
run: |
|
|
||||||
which ssh || (apt-get update && apt-get install -y openssh-client)
|
|
||||||
ssh -V
|
|
||||||
|
|
||||||
- name: Debug environment
|
|
||||||
run: |
|
|
||||||
echo "=== Environment ==="
|
|
||||||
echo "Runner hostname: $(hostname)"
|
|
||||||
echo "Runner IP: $(hostname -i || echo 'unknown')"
|
|
||||||
echo "Current user: $(whoami)"
|
|
||||||
echo "=== Secrets check ==="
|
|
||||||
if [ -n "$STAGING_SSH_HOST" ]; then
|
|
||||||
echo "STAGING_SSH_HOST: [SET] value_length=${#STAGING_SSH_HOST}"
|
|
||||||
else
|
|
||||||
echo "STAGING_SSH_HOST: [EMPTY]"
|
|
||||||
fi
|
|
||||||
if [ -n "$STAGING_SSH_USER" ]; then
|
|
||||||
echo "STAGING_SSH_USER: [SET] value_length=${#STAGING_SSH_USER}"
|
|
||||||
else
|
|
||||||
echo "STAGING_SSH_USER: [EMPTY]"
|
|
||||||
fi
|
|
||||||
if [ -n "$STAGING_SSH_KEY" ]; then
|
|
||||||
echo "STAGING_SSH_KEY: [SET] value_length=${#STAGING_SSH_KEY}"
|
|
||||||
else
|
|
||||||
echo "STAGING_SSH_KEY: [EMPTY]"
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
STAGING_SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
|
|
||||||
STAGING_SSH_USER: ${{ secrets.STAGING_SSH_USER }}
|
|
||||||
STAGING_SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
|
|
||||||
|
|
||||||
- name: Setup SSH key
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
chmod 700 ~/.ssh
|
|
||||||
echo "$STAGING_SSH_KEY" > ~/.ssh/id_ed25519
|
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
|
||||||
ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub 2>/dev/null || echo "No public key generated"
|
|
||||||
echo "=== SSH Key fingerprint ==="
|
|
||||||
ssh-keygen -lf ~/.ssh/id_ed25519 || echo "Key fingerprint failed"
|
|
||||||
env:
|
|
||||||
STAGING_SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
|
|
||||||
|
|
||||||
- name: Test SSH connection
|
|
||||||
run: |
|
|
||||||
echo "Attempting SSH connection to $STAGING_SSH_HOST..."
|
|
||||||
ssh -i ~/.ssh/id_ed25519 \
|
|
||||||
-o StrictHostKeyChecking=no \
|
|
||||||
-o UserKnownHostsFile=/dev/null \
|
|
||||||
-o ConnectTimeout=10 \
|
|
||||||
-o BatchMode=yes \
|
|
||||||
-v \
|
|
||||||
$STAGING_SSH_USER@$STAGING_SSH_HOST "echo 'SSH_CONNECTION_SUCCESS' && hostname && whoami"
|
|
||||||
echo "=== SSH Test Complete ==="
|
|
||||||
env:
|
|
||||||
STAGING_SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
|
|
||||||
STAGING_SSH_USER: ${{ secrets.STAGING_SSH_USER }}
|
|
||||||
@@ -5,7 +5,9 @@ ARG VITE_API_URL=https://saas-api.xiaoxiajianji.com
|
|||||||
ENV VITE_API_URL=$VITE_API_URL
|
ENV VITE_API_URL=$VITE_API_URL
|
||||||
COPY apps/web/package.json apps/web/package-lock.json ./apps/web/
|
COPY apps/web/package.json apps/web/package-lock.json ./apps/web/
|
||||||
WORKDIR /app/apps/web
|
WORKDIR /app/apps/web
|
||||||
RUN npm config set registry https://registry.npmmirror.com \
|
RUN \
|
||||||
|
--mount=type=cache,target=/root/.npm \
|
||||||
|
npm config set registry https://registry.npmmirror.com \
|
||||||
&& npm ci
|
&& npm ci
|
||||||
COPY apps/web/ ./
|
COPY apps/web/ ./
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|||||||
@@ -72,28 +72,25 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=== Building Web image (with buildx cache) ==="
|
echo "=== Building Web image (with buildx cache) ==="
|
||||||
# 先构建前端产物
|
# 使用多阶段 Dockerfile 构建,配合 buildx cache 缓存 npm 安装和构建产物
|
||||||
docker run --rm \
|
WEB_NGINX_CONF="${WEB_NGINX_CONF:-infra/docker/nginx-production.conf}"
|
||||||
-v "$PWD:/workspace" \
|
WEB_API_URL="${VITE_API_URL:-https://saas-api.xiaoxiajianji.com}"
|
||||||
-w /workspace/apps/web \
|
|
||||||
docker.m.daocloud.io/library/node:20 \
|
|
||||||
sh -lc "npm ci && npm run build"
|
|
||||||
|
|
||||||
test -f apps/web/dist/index.html
|
|
||||||
|
|
||||||
if [ "$USE_CACHE" -eq 1 ]; then
|
if [ "$USE_CACHE" -eq 1 ]; then
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--cache-from "type=registry,ref=${CACHE_REGISTRY}/web-cache:${CACHE_TAG},ignore-error=true" \
|
--cache-from "type=registry,ref=${CACHE_REGISTRY}/web-cache:${CACHE_TAG},ignore-error=true" \
|
||||||
--cache-to "type=registry,ref=${CACHE_REGISTRY}/web-cache:${CACHE_TAG},mode=max" \
|
--cache-to "type=registry,ref=${CACHE_REGISTRY}/web-cache:${CACHE_TAG},mode=max" \
|
||||||
-f infra/docker/web-artifact.Dockerfile \
|
-f infra/docker/web.Dockerfile \
|
||||||
--build-arg NGINX_CONF=infra/docker/nginx-production.conf \
|
--build-arg NGINX_CONF="${WEB_NGINX_CONF}" \
|
||||||
|
--build-arg VITE_API_URL="${WEB_API_URL}" \
|
||||||
-t "$WEB_IMAGE" \
|
-t "$WEB_IMAGE" \
|
||||||
--load \
|
--load \
|
||||||
.
|
.
|
||||||
else
|
else
|
||||||
docker build --pull=false \
|
docker build --pull=false \
|
||||||
-f infra/docker/web-artifact.Dockerfile \
|
-f infra/docker/web.Dockerfile \
|
||||||
--build-arg NGINX_CONF=infra/docker/nginx-production.conf \
|
--build-arg NGINX_CONF="${WEB_NGINX_CONF}" \
|
||||||
|
--build-arg VITE_API_URL="${WEB_API_URL}" \
|
||||||
-t "$WEB_IMAGE" \
|
-t "$WEB_IMAGE" \
|
||||||
.
|
.
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user