Update docker-publish.yml
This commit is contained in:
1 parent
f14a43e573
commit
12a42e5405
1 file changed
+23
-4
@@ -1,8 +1,14 @@
|
||||
name: Build and Publish MicroWARP
|
||||
|
||||
# ==========================================
|
||||
# 触发条件:
|
||||
# 1. 每次 Push 代码到 main, master 或 dev 分支
|
||||
# 2. 发布 Release 版本时
|
||||
# 3. 手动点击触发按钮
|
||||
# ==========================================
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "master" ]
|
||||
branches:[ "main", "master", "dev" ]
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
@@ -14,31 +20,44 @@ env:
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Extract metadata
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
# 1. 如果是打 Tag 发版,生成严格的版本号标签 (如 1.0.0)
|
||||
type=semver,pattern={{version}}
|
||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
|
||||
- name: Build and push
|
||||
|
||||
# 2. 【核心隔离】仅当 Push 到 main/master,或发版时,才打 latest 标签!
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event_name == 'release' }}
|
||||
|
||||
# 3. 【新增分支】仅当 Push 到 dev 分支时,才打 dev 标签!(绝不污染 latest)
|
||||
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
|
||||
Reference in new issue
Block a user