ci: update docker workflow to only build on releases

This commit is contained in:
remsky 2025-01-04 02:50:45 -07:00
parent fe114c3367
commit 65bf15f153

View file

@ -2,20 +2,7 @@ name: Docker Build and Publish
on: on:
push: push:
branches: [ "master" ]
tags: [ 'v*.*.*' ] tags: [ 'v*.*.*' ]
paths:
- '**.py'
- '**/Dockerfile*'
- '**/docker-compose*.yml'
- 'requirements*.txt'
pull_request:
branches: [ "master" ]
paths:
- '**.py'
- '**/Dockerfile*'
- '**/docker-compose*.yml'
- 'requirements*.txt'
# Allow manual trigger from GitHub UI # Allow manual trigger from GitHub UI
workflow_dispatch: workflow_dispatch:
@ -35,7 +22,6 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Log in to the Container registry - name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
@ -49,13 +35,9 @@ jobs:
with: with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: | tags: |
type=raw,value=latest
type=ref,event=branch
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}} type=semver,pattern={{major}}
type=sha
# Extract metadata for CPU image # Extract metadata for CPU image
- name: Extract metadata (tags, labels) for CPU Docker - name: Extract metadata (tags, labels) for CPU Docker
@ -66,13 +48,9 @@ jobs:
flavor: | flavor: |
suffix=-cpu suffix=-cpu
tags: | tags: |
type=raw,value=latest
type=ref,event=branch
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}} type=semver,pattern={{major}}
type=sha
# Build and push GPU version # Build and push GPU version
- name: Build and push GPU Docker image - name: Build and push GPU Docker image
@ -80,7 +58,7 @@ jobs:
with: with:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }} push: true
tags: ${{ steps.meta-gpu.outputs.tags }} tags: ${{ steps.meta-gpu.outputs.tags }}
labels: ${{ steps.meta-gpu.outputs.labels }} labels: ${{ steps.meta-gpu.outputs.labels }}
platforms: linux/amd64 platforms: linux/amd64
@ -91,7 +69,7 @@ jobs:
with: with:
context: . context: .
file: ./Dockerfile.cpu file: ./Dockerfile.cpu
push: ${{ github.event_name != 'pull_request' }} push: true
tags: ${{ steps.meta-cpu.outputs.tags }} tags: ${{ steps.meta-cpu.outputs.tags }}
labels: ${{ steps.meta-cpu.outputs.labels }} labels: ${{ steps.meta-cpu.outputs.labels }}
platforms: linux/amd64 platforms: linux/amd64
@ -105,13 +83,9 @@ jobs:
flavor: | flavor: |
suffix=-ui suffix=-ui
tags: | tags: |
type=raw,value=latest
type=ref,event=branch
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}} type=semver,pattern={{major}}
type=sha
# Build and push UI version # Build and push UI version
- name: Build and push UI Docker image - name: Build and push UI Docker image
@ -119,7 +93,7 @@ jobs:
with: with:
context: ./ui context: ./ui
file: ./ui/Dockerfile file: ./ui/Dockerfile
push: ${{ github.event_name != 'pull_request' }} push: true
tags: ${{ steps.meta-ui.outputs.tags }} tags: ${{ steps.meta-ui.outputs.tags }}
labels: ${{ steps.meta-ui.outputs.labels }} labels: ${{ steps.meta-ui.outputs.labels }}
platforms: linux/amd64 platforms: linux/amd64