Files
new-api/.github/workflows/docker-image-sd2.yml
T
t0ng7u 3ac5f1718b ci: add docker build workflow for feat/doubao-asset branch
Publish multi-arch image to t0ng7u/new-api-sd2 on Docker Hub, triggered on push to feat/doubao-asset and manual dispatch. Uses a dedicated DOCKERHUB_SD2_TOKEN secret to avoid clashing with the main branch CI credentials.
2026-07-01 01:23:49 +08:00

124 lines
3.3 KiB
YAML

name: Publish Docker image (sd2)
on:
push:
branches:
- feat/doubao-asset
workflow_dispatch:
inputs:
name:
description: "reason"
required: false
env:
IMAGE: t0ng7u/new-api-sd2
jobs:
build_single_arch:
name: Build & push (${{ matrix.arch }}) [native]
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-latest
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
steps:
- name: Check out (shallow)
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Determine version
id: version
run: |
VERSION="sd2-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
echo "$VERSION" > VERSION
echo "value=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Publishing version: $VERSION for ${{ matrix.arch }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: t0ng7u
password: ${{ secrets.DOCKERHUB_SD2_TOKEN }}
- name: Extract metadata (labels)
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE }}
- name: Build & push single-arch
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
push: true
tags: |
${{ env.IMAGE }}:latest-${{ matrix.arch }}
${{ env.IMAGE }}:${{ steps.version.outputs.value }}-${{ matrix.arch }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
sbom: false
create_manifests:
name: Create multi-arch manifests (Docker Hub)
needs: [build_single_arch]
runs-on: ubuntu-latest
steps:
- name: Check out (shallow)
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Determine version
id: version
run: |
VERSION="sd2-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
echo "value=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: t0ng7u
password: ${{ secrets.DOCKERHUB_SD2_TOKEN }}
- name: Create & push manifest (Docker Hub - latest)
run: |
docker buildx imagetools create \
-t ${IMAGE}:latest \
${IMAGE}:latest-amd64 \
${IMAGE}:latest-arm64
- name: Create & push manifest (Docker Hub - versioned)
run: |
docker buildx imagetools create \
-t ${IMAGE}:${VERSION} \
${IMAGE}:${VERSION}-amd64 \
${IMAGE}:${VERSION}-arm64
- name: Manifest summary
run: |
echo "### Multi-arch Manifest" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
docker buildx imagetools inspect ${IMAGE}:latest >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY