mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-04 07:43:28 +08:00
98 lines
2.4 KiB
YAML
98 lines
2.4 KiB
YAML
name: Frontend CI/CD
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'ui/**'
|
|
- '.github/workflows/frontend-ci-cd.yml'
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
paths:
|
|
- 'ui/**'
|
|
- '.github/workflows/frontend-ci-cd.yml'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./ui
|
|
outputs:
|
|
version: ${{ steps.get_version.outputs.VERSION }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Set up pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
|
|
- name: Get pnpm store directory
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Build frontend
|
|
run:
|
|
echo "VITE_APP_VERSION=${{ steps.get_version.outputs.VERSION }}" >> .env.production
|
|
pnpm run build
|
|
|
|
- name: 'Tar files'
|
|
run: tar -cvf dist.tar dist
|
|
|
|
package:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: frontend-build
|
|
|
|
- name: Extract files
|
|
run: |
|
|
tar -xvf dist.tar
|
|
|
|
- name: Check file structure
|
|
run: |
|
|
echo "Current directory: $(pwd)"
|
|
echo "Listing dist directory:"
|
|
ls -la dist
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Aliyun Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: chaitin-registry.cn-hangzhou.cr.aliyuncs.com
|
|
username: ${{ secrets.CT_ALIYUN_USER }}
|
|
password: ${{ secrets.CT_ALIYUN_PASS }}
|
|
|
|
- name: Package and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./ui
|
|
file: ./ui/Dockerfile
|
|
push: true
|
|
platforms: linux/amd64, linux/arm64
|
|
tags: chaitin-registry.cn-hangzhou.cr.aliyuncs.com/chaitin/monkey-code-frontend:v${{ needs.build.outputs.version }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|