Skip to content

Merge pull request #4 from xxcheng123/develop #5

Merge pull request #4 from xxcheng123/develop

Merge pull request #4 from xxcheng123/develop #5

Workflow file for this run

name: docker-image
on:
push:
tags:
- 'v*' # 当推送 v* 标签时触发,如 v1.0.0
workflow_dispatch: # 允许手动触发
inputs:
tag:
description: 'Release tag (e.g., v1.0.0)'
required: true
type: string
env:
APP_NAME: cloudpan189-share
DOCKERHUB_REPO: xxcheng123/cloudpan189-share
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
- name: 🔧 Set up QEMU
uses: docker/setup-qemu-action@v3
- name: 🔧 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🔑 Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 📊 Generate App Version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "APP_VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "APP_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: 🔨 Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64 # 移除 linux/386
push: true
build-args: |
APP_NAME=${{ env.APP_NAME }}
APP_VERSION=${{ env.APP_VERSION }}
tags: |
${{ env.DOCKERHUB_REPO }}:latest
${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 📋 Docker Image Info
run: |
echo "🎉 Docker 镜像构建完成!"
echo "📦 镜像标签:"
echo " - ${{ env.DOCKERHUB_REPO }}:latest"
echo " - ${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}"
echo ""
echo "🚀 使用方法:"
echo " docker run -p 12395:12395 ${{ env.DOCKERHUB_REPO }}:latest"