mirror of
https://github.com/luckjiawei/podux.git
synced 2026-11-30 00:56:47 +00:00
127 lines
3.7 KiB
YAML
127 lines
3.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
# ──────────────────────────────────────────────
|
|
# Frontend: lint + build
|
|
# ──────────────────────────────────────────────
|
|
frontend:
|
|
name: Frontend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
with:
|
|
version: '10'
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: pnpm
|
|
cache-dependency-path: site/pnpm-lock.yaml
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
working-directory: site
|
|
|
|
- name: Type check
|
|
run: pnpm run tsc --noEmit 2>/dev/null || pnpm exec tsc --noEmit
|
|
working-directory: site
|
|
continue-on-error: true
|
|
|
|
- name: Build
|
|
run: pnpm run build
|
|
working-directory: site
|
|
|
|
- name: Upload frontend dist
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: frontend-dist
|
|
path: site/dist/
|
|
retention-days: 1
|
|
|
|
# ──────────────────────────────────────────────
|
|
# Backend: vet + build (linux/amd64 only for speed)
|
|
# ──────────────────────────────────────────────
|
|
backend:
|
|
name: Backend
|
|
needs: frontend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Download frontend dist
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: frontend-dist
|
|
path: pb_public/
|
|
|
|
- name: go vet
|
|
run: go vet ./...
|
|
|
|
- name: Build (linux/amd64)
|
|
env:
|
|
CGO_ENABLED: '0'
|
|
GOOS: linux
|
|
GOARCH: amd64
|
|
run: |
|
|
go build \
|
|
-trimpath \
|
|
-ldflags "-s -w -X main.Version=ci -X main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
|
-o /tmp/podux \
|
|
main.go
|
|
|
|
# ──────────────────────────────────────────────
|
|
# Docker: build & push :dev image (dev branch only)
|
|
# ──────────────────────────────────────────────
|
|
docker-dev:
|
|
name: Docker (dev tag)
|
|
if: github.ref == 'refs/heads/dev' && github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
push: true
|
|
tags: ghcr.io/${{ github.repository }}:dev
|
|
build-args: |
|
|
VERSION=dev
|
|
BUILD_TIME=${{ github.event.head_commit.timestamp }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|