feat: 添加sukaka端点 #253
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: Docker Build and Push | |
| on: | |
| push: | |
| branches: [ '**' ] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: linux | |
| arch: amd64 | |
| platform: linux/amd64 | |
| - target: linux-arm64 | |
| arch: arm64 | |
| platform: linux/arm64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: src/go/cloudcode_bridge/go.mod | |
| cache-dependency-path: src/go/cloudcode_bridge/go.sum | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Prepare config file | |
| run: | | |
| if [ ! -f config.json ]; then | |
| cp config.json.example config.json | |
| fi | |
| - name: Build binary for ${{ matrix.target }} | |
| run: npm run build:${{ matrix.target }} | |
| - name: List dist contents | |
| run: | | |
| echo "=== dist directory contents ===" | |
| ls -la dist/ | |
| - name: Set lowercase image name | |
| id: image | |
| run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Generate branch slug | |
| id: branch | |
| run: | | |
| BRANCH_SLUG=$(echo "${{ github.ref_name }}" | tr '[:upper:]' '[:lower:]' | sed 's#[^a-z0-9._-]#-#g') | |
| echo "slug=${BRANCH_SLUG}" >> $GITHUB_OUTPUT | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate Docker tags | |
| id: tags | |
| run: | | |
| IMAGE_BASE="${{ env.REGISTRY }}/${{ steps.image.outputs.name }}" | |
| BRANCH="${{ github.ref_name }}" | |
| BRANCH_SLUG="${{ steps.branch.outputs.slug }}" | |
| ARCH="${{ matrix.arch }}" | |
| if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then | |
| IMAGE="${IMAGE_BASE}" | |
| TAGS="${IMAGE}:${BRANCH}-${ARCH},${IMAGE}:latest-${ARCH}" | |
| else | |
| IMAGE="${IMAGE_BASE}-exp" | |
| TAGS="${IMAGE}:${BRANCH_SLUG}-${ARCH}" | |
| fi | |
| echo "image=${IMAGE}" >> $GITHUB_OUTPUT | |
| echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image (${{ matrix.arch }}) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile.binary | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| tags: ${{ steps.tags.outputs.tags }} | |
| # 关键:让 buildx 能访问本地文件 | |
| outputs: type=image,push=true | |
| cache-from: type=gha,scope=${{ matrix.arch }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.arch }} | |
| create-manifest: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Set lowercase image name | |
| id: image | |
| run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and push multi-arch manifest | |
| run: | | |
| IMAGE="${{ env.REGISTRY }}/${{ steps.image.outputs.name }}" | |
| docker buildx imagetools create -t ${IMAGE}:latest \ | |
| ${IMAGE}:latest-amd64 \ | |
| ${IMAGE}:latest-arm64 | |
| docker buildx imagetools create -t ${IMAGE}:main \ | |
| ${IMAGE}:main-amd64 \ | |
| ${IMAGE}:main-arm64 |