build
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 5m57s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 5m57s
This commit is contained in:
@@ -1,43 +1,45 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
# name: 构建项目
|
||||
# run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
# 当代码推送到 main 分支时触发
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
# # 2. 触发条件 (on)
|
||||
# on: [push]
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# # 3. 作业定义 (jobs)
|
||||
# jobs:
|
||||
# 构建:
|
||||
# # 4. 运行器选择 (runs-on)
|
||||
# runs-on: ubuntu-latest
|
||||
|
||||
# # 5. 步骤序列 (steps)
|
||||
# steps:
|
||||
# # 步骤 1: 检出代码
|
||||
# - name: 检出代码
|
||||
# uses: https://gitea.com/actions/checkout@v4
|
||||
steps:
|
||||
# 步骤 1: 检出你的代码仓库
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# - name: 显示目录
|
||||
# run: ls -la
|
||||
# 步骤 2: 设置 Docker Buildx (推荐,支持多平台构建等高级功能)
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# # 步骤 2: 设置 Node.js 环境
|
||||
# - name: 设置 Node.js 环境
|
||||
# uses: https://gitea.com/actions/setup-node@v4
|
||||
# with:
|
||||
# node-version: 22
|
||||
# cache: 'npm'
|
||||
# 步骤 3: 登录到你的 Docker 仓库
|
||||
# 你需要在 Gitea/GitHub 的 Secrets 中配置好 DOCKERHUB_USERNAME 和 DOCKERHUB_TOKEN
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.bmycode.help
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# # 步骤 3: 安装依赖
|
||||
# - name: 安装依赖
|
||||
# run: npm ci
|
||||
|
||||
# # 步骤 4: 执行打包命令
|
||||
# - name: 执行Build构建
|
||||
# run: npm run build
|
||||
|
||||
# # 步骤 5: 上传打包产物
|
||||
# - name: 上传构建产物
|
||||
# uses: https://gitea.com/actions/upload-artifact@v3
|
||||
# with:
|
||||
# name: dist
|
||||
# path: dist/
|
||||
# 步骤 4: 构建并推送 Docker 镜像 (核心步骤)
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
# context: . 表示 Docker 构建上下文为当前仓库的根目录
|
||||
# 这意味着 Dockerfile 中 COPY . . 会复制整个项目代码
|
||||
context: .
|
||||
|
||||
# push: true 表示构建成功后将镜像推送到仓库
|
||||
push: true
|
||||
|
||||
# tags: 定义镜像的名称和标签
|
||||
# 推荐使用 commit sha 作为标签,便于版本追溯
|
||||
tags: |
|
||||
registry.bmycode.help/app-product:latest
|
||||
registry.bmycode.help/app-product:${{ github.sha }}
|
||||
Reference in New Issue
Block a user