File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Docker
1+ name : Build and Publish Docker Image
22
33on :
44 push :
5- branches : [main]
5+ branches :
6+ - main
7+ tags :
8+ - " v*"
9+ pull_request :
10+ branches :
11+ - main
612
713env :
814 REGISTRY : ghcr.io
915 IMAGE_NAME : ${{ github.repository }}
1016
1117jobs :
1218 build-and-push :
13- name : Build & Push Docker Image
1419 runs-on : ubuntu-latest
1520 permissions :
1621 contents : read
1722 packages : write
1823
1924 steps :
20- - name : Checkout code
25+ - name : Checkout repository
2126 uses : actions/checkout@v4
2227
28+ - name : Set up Docker Buildx
29+ uses : docker/setup-buildx-action@v3
30+
2331 - name : Log in to Container Registry
32+ if : github.event_name != 'pull_request'
2433 uses : docker/login-action@v3
2534 with :
2635 registry : ${{ env.REGISTRY }}
@@ -33,13 +42,18 @@ jobs:
3342 with :
3443 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3544 tags : |
36- type=raw,value=latest
45+ type=ref,event=branch
46+ type=ref,event=pr
47+ type=semver,pattern={{version}}
48+ type=semver,pattern={{major}}.{{minor}}
3749 type=sha,prefix=
3850
3951 - name : Build and push Docker image
4052 uses : docker/build-push-action@v6
4153 with :
4254 context : .
43- push : true
55+ push : ${{ github.event_name != 'pull_request' }}
4456 tags : ${{ steps.meta.outputs.tags }}
4557 labels : ${{ steps.meta.outputs.labels }}
58+ cache-from : type=gha
59+ cache-to : type=gha,mode=max
You can’t perform that action at this time.
0 commit comments