1
1
name : Build Docker Images
2
2
3
3
env :
4
- BASE_TAG : ghcr.io/${{ github.repository_owner }}/database-backup
4
+ DOCKERHUB_TAG : ' jandi/database-backup'
5
+ GITHUB_TAG : ' ghcr.io/jan-di/database-backup'
6
+ PLATFORMS : linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
5
7
6
8
on :
7
9
push :
8
- branches :
9
- - master
10
+ branches :
11
+ - ' main'
12
+ tags :
13
+ - ' v*'
14
+ pull_request :
15
+ branches :
16
+ - ' main'
10
17
11
18
jobs :
12
19
multi :
@@ -16,25 +23,50 @@ jobs:
16
23
name : Checkout
17
24
uses : actions/checkout@v2
18
25
-
19
- name : Set up QEMU
20
- uses : docker/setup-qemu-action@v1
26
+ name : Docker Metadata
27
+ id : docker_meta
28
+ uses : docker/metadata-action@v3
29
+ with :
30
+ images : |
31
+ ${{ env.DOCKERHUB_TAG }}
32
+ ${{ env.GITHUB_TAG }}
33
+ tags : |
34
+ type=ref,event=branch
35
+ type=ref,event=pr
36
+ type=semver,pattern={{version}}
37
+ type=semver,pattern={{major}}.{{minor}}
38
+ type=semver,pattern={{major}}
39
+ type=sha
21
40
-
22
- name : Set up Docker Buildx
23
- uses : docker/setup-buildx-action@v1
41
+ name : Login to DockerHub
42
+ if : github.event_name != 'pull_request'
43
+ uses : docker/login-action@v1
44
+ with :
45
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
46
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
24
47
-
25
48
name : Login to GitHub Container Registry
49
+ if : github.event_name != 'pull_request'
26
50
uses : docker/login-action@v1
27
51
with :
28
52
registry : ghcr.io
29
53
username : ${{ github.repository_owner }}
30
- password : ${{ secrets.CR_PAT }}
54
+ password : ${{ secrets.GITHUB_TOKEN }}
55
+ -
56
+ name : Set up QEMU
57
+ uses : docker/setup-qemu-action@v1
58
+ -
59
+ name : Set up Docker Buildx
60
+ uses : docker/setup-buildx-action@v1
31
61
-
32
62
name : Build and push
33
63
uses : docker/build-push-action@v2
34
64
with :
35
- platforms : linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
36
- push : true
37
- cache-from : type=registry,ref=${{ env.BASE_TAG }}:latest
65
+ context : .
66
+ file : ./Dockerfile
67
+ push : ${{ github.event_name != 'pull_request' }}
68
+ tags : ${{ steps.docker_meta.outputs.tags }}
69
+ labels : ${{ steps.docker_meta.outputs.labels }}
70
+ platforms : ${{ env.PLATFORMS }}
71
+ cache-from : type=registry,ref=${{ env.GITHUB_TAG }}:main
38
72
cache-to : type=inline
39
- tags : |
40
- ${{ env.BASE_TAG }}:latest
0 commit comments