Repository navigation
64 lines (61 loc) · 2.35 KB
/
Copy pathdocker.yml
File metadata and controls
64 lines (61 loc) · 2.35 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
# Builds the Probyte images (the app, which is also the calendar server, and the document converter) and pushes them to Docker Hub when a release is tagged (git tag v0.2.0 && git push --tags),
# or by hand from the Actions tab. Needs two repository secrets: DOCKERHUB_USERNAME and DOCKERHUB_TOKEN
# (a Docker Hub access token with read & write access: hub.docker.com → Account settings → Personal access tokens).
name: Docker images
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
images:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: probyte
context: .
- image: probyte-office
context: ./office
steps:
- id: check
env:
TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
if [ -z "$TOKEN" ]; then
echo "::notice::DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets aren't set: nothing is pushed (see the comment at the top of this workflow)."
echo "ok=false" >> "$GITHUB_OUTPUT"
else
echo "ok=true" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v4
if: steps.check.outputs.ok == 'true'
- uses: docker/setup-buildx-action@v3
if: steps.check.outputs.ok == 'true'
- uses: docker/login-action@v3
if: steps.check.outputs.ok == 'true'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
if: steps.check.outputs.ok == 'true'
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,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=sha,prefix=sha-
- uses: docker/build-push-action@v6
if: steps.check.outputs.ok == 'true'
with:
context: ${{ matrix.context }}
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ steps.meta.outputs.version }}
cache-from: type=gha,scope=${{ matrix.image }}
cache-to: type=gha,mode=max,scope=${{ matrix.image }}