-
Notifications
You must be signed in to change notification settings - Fork 24
95 lines (83 loc) · 2.74 KB
/
docker-publish.yml
File metadata and controls
95 lines (83 loc) · 2.74 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Docker
# This workflow builds Docker images on push to main/dev branches
# and publishes (pushes) them to GHCR on version tags.
on:
push:
branches:
- main
- dev
tags:
- "v*"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- context: .
file: server/Dockerfile
image: ghcr.io/${{ github.repository }}-backend
- context: ui
file: ui/Dockerfile
image: ghcr.io/${{ github.repository }}-frontend
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: "true"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
# Only login if we are going to push
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
# Tag with the exact git tag
type=ref,event=tag
# Extract version from tag (stripping 'v' prefix if present)
type=match,pattern=v(.*),group=1
# Standard semver (if valid)
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Branch and SHA
type=ref,event=branch
type=sha
# latest tag only for stable releases (no 'a', 'b', 'rc' etc. in the tag name)
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref_name, 'a') && !contains(github.ref_name, 'b') && !contains(github.ref_name, 'rc') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
# Only push on tags
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max