11name : Build Docker Images
22
33env :
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
57
68on :
79 push :
8- branches :
9- - master
10+ branches :
11+ - ' main'
12+ tags :
13+ - ' v*'
14+ pull_request :
15+ branches :
16+ - ' main'
1017
1118jobs :
1219 multi :
@@ -16,25 +23,50 @@ jobs:
1623 name : Checkout
1724 uses : actions/checkout@v2
1825 -
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
2140 -
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 }}
2447 -
2548 name : Login to GitHub Container Registry
49+ if : github.event_name != 'pull_request'
2650 uses : docker/login-action@v1
2751 with :
2852 registry : ghcr.io
2953 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
3161 -
3262 name : Build and push
3363 uses : docker/build-push-action@v2
3464 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
3872 cache-to : type=inline
39- tags : |
40- ${{ env.BASE_TAG }}:latest
0 commit comments