Files
Mofox-Core/.github/workflows/docker-image.yml
2025-03-04 11:03:57 +08:00

39 lines
1.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Docker Build and Push
on:
push:
branches:
- main # 推送到main分支时触发
tags:
- 'v*' # 推送v开头的tag时触发例如v1.0.0
workflow_dispatch: # 允许手动触发
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: . # Docker构建上下文路径
file: ./Dockerfile # Dockerfile路径
platforms: linux/amd64,linux/arm64 # 支持arm架构
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/maimbot:${{ github.ref_name }}
${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest
push: true
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest
cache-to: type=inline