第二天测试
Some checks failed
Build and Push Docker Images / build-and-push (backend) (push) Failing after 1m1s
Build and Push Docker Images / build-and-push (frontend) (push) Failing after 1m13s

This commit is contained in:
小贺
2025-09-04 09:40:12 +08:00
parent 7e543935ef
commit b1d64ef64b
2 changed files with 27 additions and 57 deletions

View File

@@ -2,10 +2,10 @@ name: Build and Push Docker Images
on: on:
push: push:
branches: [ main ] branches: [ main, develop ]
tags: [ 'v*' ] tags: [ 'v*' ]
pull_request: pull_request:
branches: [ main ] branches: [ main, develop ]
jobs: jobs:
build-and-push: build-and-push:
@@ -17,17 +17,11 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整的提交历史用于标签生成
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:latest
install: true
network: host
buildkitd-config-inline: |
[registry."gitea.zfxt.top:8443"]
http = true
insecure = true
- name: Login to Registry - name: Login to Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
@@ -36,18 +30,23 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }} username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.REGISTRY_PASSWORD }}
# - name: Extract metadata for backend # 为后端服务生成元数据
# if: matrix.service == 'backend' - name: Extract metadata for backend
# id: meta-backend if: matrix.service == 'backend'
# uses: docker/metadata-action@v5 id: meta-backend
# with: uses: docker/metadata-action@v5
# images: gitea.zfxt.top/zfxt/backend with:
# tags: | images: gitea.zfxt.top/zfxt/backend
# type=ref,event=branch tags: |
# type=ref,event=pr type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
# type=semver,pattern={{version}} type=sha,prefix=,suffix=,enable=true
# type=semver,pattern={{major}}.{{minor}} type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# 为前端服务生成元数据
- name: Extract metadata for frontend - name: Extract metadata for frontend
if: matrix.service == 'frontend' if: matrix.service == 'frontend'
id: meta-frontend id: meta-frontend
@@ -55,11 +54,15 @@ jobs:
with: with:
images: gitea.zfxt.top/zfxt/frontend images: gitea.zfxt.top/zfxt/frontend
tags: | tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,prefix=,suffix=,enable=true
type=ref,event=branch type=ref,event=branch
type=ref,event=pr type=ref,event=pr
type=semver,pattern={{version}} type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# 构建和推送后端镜像
- name: Build and push backend image - name: Build and push backend image
if: matrix.service == 'backend' if: matrix.service == 'backend'
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@@ -67,9 +70,8 @@ jobs:
context: ./backend context: ./backend
file: ./backend/dockerfile file: ./backend/dockerfile
push: true push: true
tags: "gitea.zfxt.top/zfxt/backend:latest" tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }} # 构建和推送前端镜像
- name: Build and push frontend image - name: Build and push frontend image
if: matrix.service == 'frontend' if: matrix.service == 'frontend'
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@@ -78,4 +80,4 @@ jobs:
file: ./front/dockerfile file: ./front/dockerfile
push: true push: true
tags: ${{ steps.meta-frontend.outputs.tags }} tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}

View File

@@ -1,32 +0,0 @@
name: Build and Push Docker Image
on: [push] # 在每次 push 时触发
jobs:
build-and-push:
runs-on: ubuntu-latest # 使用 Ubuntu 环境运行
steps:
# 步骤1: 检出仓库代码
- name: Checkout code
uses: actions/checkout@v4 # 使用 Gitea 官方的 checkout action
# 步骤2: 登录到 Docker Registry (你的 Gitea 仓库)
- name: Log in to Docker Registry
uses: docker/login-action@v2
with:
registry: gitea.zfxt.top
username: ${{ secrets.REGISTRY_USERNAME }} # 将用户名存储在仓库的 Secrets 中
password: ${{ secrets.REGISTRY_PASSWORD }} # 将密码或个人访问令牌存储在 Secrets 中
# 步骤3: 构建 Docker 镜像
- name: Build and Push Docker Image
uses: docker/build-push-action@v5 # 确认此插件可用
with:
context: ./backend
file: ./backend/dockerfile
push: true
tags: |
gitea.zfxt.top/zfxt/haha:v1.0