diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..5cb69a5 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,67 @@ +name: CI Pipeline + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "18" # 根据需要修改 Node.js 版本 + + - name: Clone and build family-flix/api + run: | + mkdir -p /app/api + git clone https://github.com/family-flix/api /app/api + cd /app/api + npm install + npm run build + + - name: Clone and build family-flix/pc2 + run: | + mkdir -p /app/pc2 + git clone https://github.com/family-flix/pc2 /app/pc2 + cd /app/pc2 + pnpm install + npm run build + mkdir -p /app/api/dist/dist/assets/pc + mv /app/pc2/dist/* /app/api/dist/dist/assets/pc/ + + - name: Clone and build family-flix/admin1 + run: | + mkdir -p /app/admin1 + git clone https://github.com/family-flix/admin1 /app/admin1 + cd /app/admin1 + pnpm install + npm run build + mkdir -p /app/api/dist/dist/assets/admin + mv /app/admin1/dist/* /app/api/dist/dist/assets/admin/ + + - name: Clone and build family-flix/mobile1 + run: | + mkdir -p /app/mobile1 + git clone https://github.com/family-flix/mobile1 /app/mobile1 + cd /app/mobile1 + pnpm install + npm run build + mkdir -p /app/api/dist/dist/assets/mobile + mv /app/mobile1/dist/* /app/api/dist/dist/assets/mobile/ + + - name: Build Docker image + run: | + cd /app/api + VERSION=$(jq -r '.version' package.json) + docker build -t ltaoo/family_flix:$VERSION . + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin + docker push ltaoo/family_flix:$VERSION + + - name: Clean up + run: | + sudo rm -rf /app