Skip to content

refactor: update CI/CD workflows and Docker configurations for improv… #7

refactor: update CI/CD workflows and Docker configurations for improv…

refactor: update CI/CD workflows and Docker configurations for improv… #7

Workflow file for this run

# Builds Docker images to Docker Hub when a git tag is pushed
# Triggered only on: git tag -a v1.0.0 && git push origin v1.0.0
# Images appear at: dockerhub.com/your-username/nachweise-backend:1.0.0
name: Build and Push to Docker Hub
on:
push:
tags:
- "*" # Triggered on any git tag
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: nachweise-backend
context: ./backend
- image: nachweise-frontend
context: ./client-nachweise
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract tag version
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}