mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-19 03:37:27 +00:00
110 lines
3.1 KiB
YAML
110 lines
3.1 KiB
YAML
name: Publish Docker image to Docker Hub (t0ngyu/new-api-sub)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- sub
|
|
workflow_dispatch:
|
|
inputs:
|
|
name:
|
|
description: "reason"
|
|
required: false
|
|
|
|
env:
|
|
DOCKERHUB_IMAGE: t0ngyu/new-api-sub
|
|
|
|
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: Resolve version tags
|
|
id: version
|
|
run: |
|
|
SHORT_SHA="$(git rev-parse --short HEAD)"
|
|
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
|
|
echo "SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub (t0ngyu)
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.T0NGYU_DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.T0NGYU_DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build & push single-arch (Docker Hub)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
tags: |
|
|
${{ env.DOCKERHUB_IMAGE }}:latest-${{ matrix.arch }}
|
|
${{ env.DOCKERHUB_IMAGE }}:sha-${{ steps.version.outputs.short_sha }}-${{ matrix.arch }}
|
|
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
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Check out (shallow)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Resolve version tags
|
|
id: version
|
|
run: |
|
|
SHORT_SHA="$(git rev-parse --short HEAD)"
|
|
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
|
|
echo "SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub (t0ngyu)
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.T0NGYU_DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.T0NGYU_DOCKERHUB_TOKEN }}
|
|
|
|
- name: Create & push manifest (latest)
|
|
run: |
|
|
docker buildx imagetools create \
|
|
-t "${DOCKERHUB_IMAGE}:latest" \
|
|
"${DOCKERHUB_IMAGE}:latest-amd64" \
|
|
"${DOCKERHUB_IMAGE}:latest-arm64"
|
|
|
|
- name: Create & push manifest (sha)
|
|
run: |
|
|
docker buildx imagetools create \
|
|
-t "${DOCKERHUB_IMAGE}:sha-${SHORT_SHA}" \
|
|
"${DOCKERHUB_IMAGE}:sha-${SHORT_SHA}-amd64" \
|
|
"${DOCKERHUB_IMAGE}:sha-${SHORT_SHA}-arm64"
|
|
|