Skip to content

Build and Push Docker Image Workflow #12

Build and Push Docker Image Workflow

Build and Push Docker Image Workflow #12

name: Build and Push Docker Images
on:
pull_request:
paths-ignore:
- 'README.md'
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'SECURITY.md'
- 'docs/**'
- 'keycloakify/**'
- '.github/**'
- '!.github/workflows/build-and-push-docker-image.yml'
- '!.github/workflows/dev.yml'
push:
branches:
- develop
jobs:
build:
name: ${{ matrix.path }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./webapp/Dockerfile
image: ls1intum/Hephaestus/webapp
context: ./webapp
path: webapp
- dockerfile: ./server/intelligence-service/Dockerfile
image: ls1intum/Hephaestus/intelligence-service
context: ./server/intelligence-service
path: intelligence-service
- dockerfile: ./server/webhook-ingest/Dockerfile
image: ls1intum/Hephaestus/webhook-ingest
context: ./server/webhook-ingest
path: webhook-ingest
- dockerfile: ./server/application-server/Dockerfile
image: ls1intum/Hephaestus/application-server
context: ./server/application-server
path: application-server
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Install Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ matrix.image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha,prefix=,format=long
- name: Build and push Docker Image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
cache-from: type=gha,scope=${{ matrix.image }}
cache-to: type=gha,scope=${{ matrix.image }},mode=max