1- name : Publish Docker image
1+ name : ci
2+
23on :
3- release :
4- types : [published]
54 push :
6- branches : [ master ]
5+ tags :
6+ - " v*.*.*"
77 pull_request :
8- branches : [ master ]
8+ branches :
9+ - " master"
10+
911jobs :
10- push_to_registry :
11- name : Push Docker image to Docker Hub
12+ docker :
1213 runs-on : ubuntu-latest
13-
1414 steps :
15- - uses : actions/checkout@v2
16- - name : Login to DockerHub Registry
17- run : echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
18- - name : Build the Docker image
19- run : docker build . --file docker/Dockerfile --tag hascheksolutions/backupdrop:$(date +%s) --tag hascheksolutions/backupdrop:latest
20- - name : Push the Docker image to the registry
21- run : docker push hascheksolutions/backupdrop
15+ - name : Checkout
16+ uses : actions/checkout@v4
17+ - name : Docker meta
18+ id : meta
19+ uses : docker/metadata-action@v5
20+ with :
21+ # list of Docker images to use as base name for tags
22+ images : |
23+ hascheksolutions/backupdrop
24+ ghcr.io/hascheksolutions/backupdrop
25+ # generate Docker tags based on the following events/attributes
26+ tags : |
27+ type=schedule
28+ type=ref,event=branch
29+ type=ref,event=pr
30+ type=semver,pattern={{version}}
31+ type=semver,pattern={{major}}.{{minor}}
32+ type=semver,pattern={{major}}
33+ type=sha
34+ - name : Set up QEMU
35+ uses : docker/setup-qemu-action@v3
36+ - name : Set up Docker Buildx
37+ uses : docker/setup-buildx-action@v3
38+ - name : Login to Docker Hub
39+ if : github.event_name != 'pull_request'
40+ uses : docker/login-action@v3
41+ with :
42+ username : ${{ secrets.DOCKER_USERNAME }}
43+ password : ${{ secrets.DOCKER_PASSWORD }}
44+ - name : Login to GHCR
45+ if : github.event_name != 'pull_request'
46+ uses : docker/login-action@v3
47+ with :
48+ registry : ghcr.io
49+ username : ${{ github.repository_owner }}
50+ password : ${{ secrets.GITHUB_TOKEN }}
51+ - name : Build and push
52+ uses : docker/build-push-action@v5
53+ with :
54+ context : .
55+ file : docker/Dockerfile
56+ platforms : linux/amd64,linux/arm/v7,linux/arm64
57+ push : ${{ github.event_name != 'pull_request' }}
58+ tags : ${{ steps.meta.outputs.tags }}
59+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments