2024-09-16 12:02:26 +08:00
|
|
|
name: Frontend CI/CD
|
|
|
|
|
2024-09-17 13:02:47 +08:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- test
|
2024-09-16 11:40:49 +08:00
|
|
|
|
|
|
|
jobs:
|
2024-09-16 12:02:26 +08:00
|
|
|
build:
|
2024-09-17 13:02:47 +08:00
|
|
|
runs-on: ubuntu-latest
|
2024-09-16 12:02:26 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
project: [web-office]
|
2024-09-17 13:02:47 +08:00
|
|
|
|
2024-09-16 11:40:49 +08:00
|
|
|
steps:
|
2024-09-16 12:02:26 +08:00
|
|
|
|
2024-09-17 13:02:47 +08:00
|
|
|
# Output Node.js and npm version
|
|
|
|
- name: Output Node.js and npm version
|
|
|
|
run: |
|
|
|
|
echo "Node.js version:"
|
|
|
|
node -v
|
|
|
|
echo "npm version:"
|
|
|
|
npm -v
|
|
|
|
corepack enable
|
|
|
|
corepack prepare pnpm@latest-9 --activate
|
|
|
|
pnpm config set store-dir .pnpm-store
|
|
|
|
echo "pnpm version:"
|
|
|
|
pnpm -v
|
2024-09-16 12:14:28 +08:00
|
|
|
|
2024-09-17 13:02:47 +08:00
|
|
|
# Clone repository
|
|
|
|
- name: Clone repository
|
|
|
|
uses: https://gitea.com/actions/checkout@v4
|
2024-09-16 12:02:26 +08:00
|
|
|
|
2024-09-17 13:02:47 +08:00
|
|
|
# Cache pnpm dependencies
|
|
|
|
- name: Cache pnpm store
|
|
|
|
uses: https://gitea.com/actions/cache@v3
|
|
|
|
id: pnpm-cache
|
|
|
|
with:
|
|
|
|
path: .pnpm-store
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-store-
|
2024-09-16 12:02:26 +08:00
|
|
|
|
2024-09-17 13:02:47 +08:00
|
|
|
# Install dependencies and build
|
|
|
|
- name: Install dependencies and build
|
|
|
|
run: |
|
|
|
|
ls
|
|
|
|
echo "Installing dependencies..."
|
|
|
|
pnpm install --no-frozen-lockfile
|
|
|
|
echo "Dependencies installed."
|
|
|
|
echo "Building project..."
|
|
|
|
pnpm build --filter ${{ matrix.project }}
|
|
|
|
echo "Project built."
|
2024-09-16 12:02:26 +08:00
|
|
|
|
2024-09-17 13:02:47 +08:00
|
|
|
# Transfer files to target server
|
|
|
|
- name: Transfer files to target server
|
2024-09-16 11:40:49 +08:00
|
|
|
run: |
|
2024-09-17 13:02:47 +08:00
|
|
|
echo "Transferring files..."
|
|
|
|
mkdir -p ~/.ssh
|
|
|
|
echo "${{ vars.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
|
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
cd apps/web-office
|
|
|
|
echo "Local files in the directory:"
|
|
|
|
ls
|
|
|
|
rsync -av --delete -e "ssh -o StrictHostKeyChecking=no -p ${{ vars.REMOTE_PORT }}" dist/ ${{ vars.REMOTE_USER }}@${{ vars.REMOTE_HOST }}:/opt/test
|
|
|
|
echo "Files transferred."
|
2024-10-08 10:14:22 +08:00
|
|
|
|