-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.42 KB
/
Copy pathdocker-hub.yml
File metadata and controls
52 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 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 }}