1+ name : Build and Push Container Image
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ tags :
8+ - ' v*'
9+ pull_request :
10+ branches :
11+ - master
12+
13+ concurrency :
14+ group : ${{ github.workflow }}-${{ github.ref }}
15+ cancel-in-progress : true
16+
17+ env :
18+ REGISTRY : ghcr.io
19+ IMAGE_NAME : ${{ github.repository }}
20+
21+ jobs :
22+ build-and-push :
23+ runs-on : ubuntu-latest
24+ permissions :
25+ contents : read
26+ packages : write
27+
28+ steps :
29+ - name : Checkout repository
30+ uses : actions/checkout@v4
31+
32+ - name : Set up Docker Buildx
33+ uses : docker/setup-buildx-action@v3
34+
35+ - name : Log in to GitHub Container Registry
36+ if : github.event_name != 'pull_request'
37+ uses : docker/login-action@v3
38+ with :
39+ registry : ${{ env.REGISTRY }}
40+ username : ${{ github.actor }}
41+ password : ${{ secrets.GITHUB_TOKEN }}
42+
43+ - name : Extract metadata (tags, labels)
44+ id : meta
45+ uses : docker/metadata-action@v5
46+ with :
47+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+ tags : |
49+ type=ref,event=branch
50+ type=ref,event=pr
51+ type=semver,pattern={{version}}
52+ type=semver,pattern={{major}}.{{minor}}
53+ type=sha
54+
55+ - name : Build and push Docker image
56+ uses : docker/build-push-action@v5
57+ with :
58+ context : .
59+ file : docker/Dockerfile.build
60+ push : ${{ github.event_name != 'pull_request' }}
61+ tags : ${{ steps.meta.outputs.tags }}
62+ labels : ${{ steps.meta.outputs.labels }}
63+ cache-from : type=gha
64+ cache-to : type=gha,mode=max
0 commit comments