-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (62 loc) · 2.03 KB
/
Copy pathdocker-image.yml
File metadata and controls
75 lines (62 loc) · 2.03 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Build & Publish Docker image
on:
push:
branches: [ "master" ]
paths-ignore:
- "README.md"
- ".github/workflows/dockerhub-description.yml"
- ".github/ISSUE_TEMPLATE/**"
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: write # erlaubt Git-Tags zu pushen
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # wichtig für git tags
- name: Calculate version
id: version
run: |
git fetch --tags
LAST_TAG=$(git tag --list "v*" --sort=-v:refname | head -n 1)
if [ -z "$LAST_TAG" ]; then
VERSION="v0.1.0"
else
IFS='.' read -r MAJOR MINOR PATCH <<< "${LAST_TAG#v}"
PATCH=$((PATCH + 1))
VERSION="v$MAJOR.$MINOR.$PATCH"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Calculated version: $VERSION"
- name: Create git tag
run: |
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_IMAGENAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ steps.version.outputs.version }}
- name: Build and push (multi-arch)
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}