mirror of
https://github.com/fish2018/pansou.git
synced 2025-11-25 03:14:59 +08:00
75 lines
1.9 KiB
YAML
75 lines
1.9 KiB
YAML
name: 构建并发布Docker镜像
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
- "master"
|
|
tags:
|
|
- "v*.*.*"
|
|
paths-ignore:
|
|
- "README.md"
|
|
- "docs/**"
|
|
pull_request:
|
|
branches:
|
|
- "main"
|
|
- "master"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: 设置QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: 设置Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
buildkitd-flags: --debug
|
|
|
|
- name: 登录到GitHub容器注册表
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: 提取Docker元数据
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/pansou
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,format=short
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: 构建并推送Docker镜像
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
build-args: |
|
|
BUILD_DATE=${{ github.event.repository.updated_at }}
|
|
VCS_REF=${{ github.sha }}
|
|
VERSION=${{ steps.meta.outputs.version }}
|