Merge pull request #76 from lingganwu/my-custom
Add GitHub Actions workflow for Docker image build
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
name: Build and Push Docker Image to Docker Hub
|
||||||
|
|
||||||
|
# 触发条件配置
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev-custom # 如果你新建了分支,确保你的分支名在这里
|
||||||
|
- my-custom # 替换为你实际使用的分支名
|
||||||
|
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 }}
|
||||||
+3
-1
@@ -30,4 +30,6 @@ ENV HERMES_HOME=/home/agent/.hermes
|
|||||||
|
|
||||||
EXPOSE 6060
|
EXPOSE 6060
|
||||||
|
|
||||||
CMD ["node", "dist/server/index.js"]
|
# 强制覆盖基础镜像的默认启动脚本,让镜像本身具备独立运行的能力
|
||||||
|
ENTRYPOINT ["node", "dist/server/index.js"]
|
||||||
|
CMD []
|
||||||
|
|||||||
Reference in New Issue
Block a user