1+ name : Build and Push Docker Image
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - master
8+ tags :
9+ - ' v*'
10+ pull_request :
11+ branches :
12+ - main
13+ - master
14+
15+ env :
16+ REGISTRY : docker.io
17+ IMAGE_NAME : flyio/percona-postgresql-operator
18+
19+ jobs :
20+ build :
21+ runs-on : ubuntu-latest
22+ permissions :
23+ contents : read
24+ packages : write
25+
26+ steps :
27+ - name : Checkout repository
28+ uses : actions/checkout@v4
29+ with :
30+ fetch-depth : 0 # Needed for git describe
31+
32+ - name : Set up QEMU
33+ uses : docker/setup-qemu-action@v3
34+
35+ - name : Set up Docker Buildx
36+ uses : docker/setup-buildx-action@v3
37+
38+ - name : Log in to Docker Hub
39+ if : github.event_name != 'pull_request'
40+ uses : docker/login-action@v3
41+ with :
42+ username : ${{ secrets.DOCKERHUB_USERNAME }}
43+ password : ${{ secrets.DOCKERHUB_TOKEN }}
44+
45+ - name : Extract metadata (tags, labels) for Docker
46+ id : meta
47+ uses : docker/metadata-action@v5
48+ with :
49+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+ tags : |
51+ type=ref,event=branch
52+ type=ref,event=pr
53+ type=semver,pattern={{version}}
54+ type=semver,pattern={{major}}.{{minor}}
55+ type=sha,format=long
56+ type=raw,value=latest,enable={{is_default_branch}}
57+
58+ - name : Get PGMonitor
59+ run : make get-pgmonitor
60+
61+ - name : Build and push Docker image
62+ uses : docker/build-push-action@v5
63+ with :
64+ context : .
65+ file : ./build/postgres-operator/Dockerfile
66+ push : ${{ github.event_name != 'pull_request' }}
67+ platforms : linux/amd64,linux/arm64
68+ tags : ${{ steps.meta.outputs.tags }}
69+ labels : ${{ steps.meta.outputs.labels }}
70+ cache-from : type=gha
71+ cache-to : type=gha,mode=max
0 commit comments