Files
vac-optimizer/.github/workflows/docker-build-push.yml
T
CopilotandTHoguet cb5f440d02 Fix Docker publish not triggering after GITHUB_TOKEN-merged PRs (#142)
* Initial plan

* Fix Docker publish not running after GITHUB_TOKEN-merged PRs

Co-authored-by: THoguet <61246905+THoguet@users.noreply.github.com>
Agent-Logs-Url: https://github.com/THoguet/vac-optimizer/sessions/6d2692bd-36b2-4000-ade6-8136fa4bbd26

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: THoguet <61246905+THoguet@users.noreply.github.com>
2026-03-23 23:51:02 +01:00

70 lines
2.2 KiB
YAML

name: Docker Build and Push
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [closed]
release:
types: [published]
workflow_dispatch:
jobs:
build-and-push:
if: github.event_name != 'pull_request' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
security-events: write
steps:
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.35.0
with:
image-ref: ghcr.io/thoguet/vac-optimizer@${{ steps.build.outputs.digest }}
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-results.sarif'