Files
CICD_Learning/.gitea/workflows/docker-build-push.yml
小贺 c333fde2e3
Some checks failed
Build and Push Docker Images / build-and-push (backend) (push) Failing after 2m5s
Build and Push Docker Images / build-and-push (frontend) (push) Failing after 2m13s
测试是否元信息出错
2025-09-03 21:49:19 +08:00

73 lines
2.0 KiB
YAML

name: Build and Push Docker Images
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
service: [frontend, backend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: gitea.zfxt.top
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# - name: Extract metadata for backend
# if: matrix.service == 'backend'
# id: meta-backend
# uses: docker/metadata-action@v5
# with:
# images: gitea.zfxt.top/zfxt/backend
# tags: |
# type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
- name: Extract metadata for frontend
if: matrix.service == 'frontend'
id: meta-frontend
uses: docker/metadata-action@v5
with:
images: gitea.zfxt.top/zfxt/frontend
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push backend image
if: matrix.service == 'backend'
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/dockerfile
push: true
tags: "gitea.zfxt.top/zfxt/backend:latest"
labels: ${{ steps.meta-backend.outputs.labels }}
- name: Build and push frontend image
if: matrix.service == 'frontend'
uses: docker/build-push-action@v5
with:
context: ./front
file: ./front/dockerfile
push: true
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}