mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 00:21:56 +08:00
- Remove legacy static files, templates, and JavaScript - Update main.go to serve SPA-style web application - Modify admin route handling to support client-side routing - Simplify configuration and metrics API endpoints - Remove server-side template rendering in favor of static file serving - Update Dockerfile and GitHub Actions to build web frontend
125 lines
3.1 KiB
YAML
125 lines
3.1 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
paths-ignore: [ '**.md','docker-compose.yml' ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build-web:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
cache-dependency-path: web/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
working-directory: web
|
|
run: npm ci
|
|
|
|
- name: Build web
|
|
working-directory: web
|
|
run: npm run build
|
|
|
|
- name: Upload web artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: web-out
|
|
path: web/out
|
|
|
|
build-backend:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [amd64, arm64]
|
|
include:
|
|
- arch: amd64
|
|
goarch: amd64
|
|
- arch: arm64
|
|
goarch: arm64
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Build binary
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
go build -o proxy-go-${{ matrix.arch }}
|
|
|
|
- name: Upload binary artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: proxy-go-${{ matrix.arch }}
|
|
path: proxy-go-${{ matrix.arch }}
|
|
|
|
docker:
|
|
needs: [build-web, build-backend]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@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 Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: woodchen
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Create Docker build context
|
|
run: |
|
|
mkdir -p docker-context
|
|
cp Dockerfile docker-context/
|
|
cp proxy-go-amd64/proxy-go-amd64 docker-context/proxy-go.amd64
|
|
cp proxy-go-arm64/proxy-go-arm64 docker-context/proxy-go.arm64
|
|
mkdir -p docker-context/web/out
|
|
cp -r web-out/* docker-context/web/out/
|
|
|
|
- name: Build and push Docker images
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: docker-context
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
woodchen/proxy-go:latest
|
|
|
|
- name: Execute deployment commands
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: root
|
|
key: ${{ secrets.SERVER_SSH_KEY }}
|
|
script: |
|
|
docker pull woodchen/proxy-go:latest
|
|
|
|
docker stop proxy-go || true
|
|
docker rm proxy-go || true
|
|
|
|
docker compose -f /opt/1panel/docker/compose/proxy-go/docker-compose.yml up -d
|
|
|