Files
litek/.gitea/workflows/build.yaml
typist a6d9c23179 feat: add deployment workflow and trigger in build.yaml
- Introduced a new deploy.yaml workflow for production deployment.
- Updated build.yaml to trigger the deployment workflow after building the Docker image.
2025-10-28 22:06:13 +08:00

58 lines
1.9 KiB
YAML

name: Build and Push Docker Image
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 登录到 Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY_ENDPOINT }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: 提取 Docker 元数据
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.REGISTRY_ENDPOINT }}/${{ github.repository_owner }}/litek
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ !contains(github.ref, 'snapshot') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') }}
- name: 构建并推送 Docker 镜像
id: build
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ secrets.REGISTRY_ENDPOINT }}/${{ github.repository_owner }}/litek:buildcache
cache-to: type=registry,ref=${{ secrets.REGISTRY_ENDPOINT }}/${{ github.repository_owner }}/litek:buildcache,mode=max
# platforms: linux/amd64,linux/arm64
platforms: linux/amd64
- name: 触发部署 workflow
uses: benc-uk/workflow-dispatch@v1
with:
workflow: deploy.yaml
token: ${{ secrets.GITHUB_TOKEN }}
inputs: '{"image_tag": "${{ github.ref_name }}"}'