fix: 切换到 arm64 平台,GraalVM 改用 glibc 标准版本 #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 构建并部署后端 | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ghcr.io/involutionhell/involutionhell-backend | |
| jobs: | |
| build-and-push: | |
| name: 编译 Native Image 并推送到 GHCR | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v4 | |
| - name: 登录 GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 设置 Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: 构建并推送镜像 | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/arm64 | |
| tags: | | |
| ${{ env.IMAGE_NAME }}:latest | |
| ${{ env.IMAGE_NAME }}:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| deploy: | |
| name: SSH 部署到服务器 | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| environment: production | |
| steps: | |
| - name: 检出代码(仅获取 docker-compose.yml 和 Caddyfile) | |
| uses: actions/checkout@v4 | |
| - name: 将 compose 文件同步到服务器 | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| source: "docker-compose.yml,Caddyfile,docker/" | |
| target: "/home/ubuntu/involution-hell" | |
| - name: 远程执行部署 | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| script: | | |
| cd /home/ubuntu/involution-hell | |
| # 写入镜像名,确保拉取最新 | |
| export BACKEND_IMAGE_NAME=${{ env.IMAGE_NAME }}:${{ github.sha }} | |
| # 登录 GHCR 后拉取镜像并重启服务 | |
| echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| docker compose pull backend | |
| docker compose up -d --remove-orphans |