Skip to content

Rename and update Docker workflow for publishing #1

Rename and update Docker workflow for publishing

Rename and update Docker workflow for publishing #1

name: Build & Push Docker Images
on:
push:
branches: ["main"]
paths:
- "frontend/**"
- "backend/**"
- "ai_service/**"
- "docker-compose.yml"
- ".github/workflows/docker.yml"
pull_request:
branches: ["main"]
paths:
- "frontend/**"
- "backend/**"
- "ai_service/**"
- ".github/workflows/docker.yml"
workflow_dispatch:
env:
REGISTRY: ghcr.io
REPOSITORY: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
service:
- name: frontend
context: ./frontend
dockerfile: ./frontend/Dockerfile
- name: backend
context: ./backend
dockerfile: ./backend/Dockerfile
- name: ai_service
context: ./ai_service
dockerfile: ./ai_service/Dockerfile
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ matrix.service.name }}
tags: |
type=ref,event=branch
type=sha,prefix=sha-,format=short
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Build and push ${{ matrix.service.name }}
id: build
uses: docker/build-push-action@v5
with:
context: ${{ matrix.service.context }}
file: ${{ matrix.service.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.service.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.service.name }}
- name: Print image digest
run: echo "${{ matrix.service.name }} digest: ${{ steps.build.outputs.digest }}"

Check failure on line 83 in .github/workflows/docker-publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/docker-publish.yml

Invalid workflow file

You have an error in your yaml syntax on line 83