anti_api / .github /workflows /docker-publish.yml
ZhaoShanGeng
ci: Docker 镜像添加 latest 标签
98fbbd6
name: Docker Build and Push
on:
push:
branches: [ '**' ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- target: linux
arch: amd64
tag_suffix: ""
- target: linux-arm64
arch: arm64
tag_suffix: "-arm64"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build binary for ${{ matrix.arch }}
run: npm run build:${{ matrix.target }}
- name: List dist contents
run: |
echo "=== dist directory contents ==="
ls -la dist/
echo "=== bin directory ==="
ls -la dist/bin/ || echo "No bin directory"
- name: Set executable permissions
run: |
chmod +x dist/antigravity-* || true
chmod +x dist/bin/* || true
- 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: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,suffix=${{ matrix.tag_suffix }}
type=raw,value=binary${{ matrix.tag_suffix }},enable=true
type=raw,value=latest${{ matrix.tag_suffix }},enable=${{ github.ref == 'refs/heads/binary-build' }}
- name: Build and push (${{ matrix.arch }})
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.binary
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max