ef39a69d11
Remove personal branch names (dev-custom, my-custom), keep only main and dev. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.3 KiB
YAML
43 lines
1.3 KiB
YAML
name: Build and Push Docker Image to Docker Hub
|
|
|
|
# 触发条件配置
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
workflow_dispatch: # 允许在 GitHub 网页端手动点击按钮触发
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# 1. 检出当前仓库代码
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
# 2. 设置 Docker Buildx (用于构建镜像的高级工具)
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# 3. 登录到 Docker Hub (使用你截图里配置的 Secrets)
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
# 4. 构建并推送镜像
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
# 根据仓库根目录的 Dockerfile 构建
|
|
file: ./Dockerfile
|
|
push: true
|
|
# 这里的标签会自动加上你的 DockerHub 用户名,以及 hermes-web-ui 仓库名
|
|
tags: |
|
|
${{ secrets.DOCKERHUB_USERNAME }}/hermes-web-ui:latest
|
|
${{ secrets.DOCKERHUB_USERNAME }}/hermes-web-ui:${{ github.sha }}
|