1616      contents : read 
1717      packages : write 
1818
19+     strategy :
20+       matrix :
21+         pg_version : [14, 15, 16, 17] 
22+ 
1923    steps :
2024      - name : Checkout repository 
2125        uses : actions/checkout@v4 
@@ -26,11 +30,11 @@ jobs:
2630      - name : Set up Docker Buildx 
2731        uses : docker/setup-buildx-action@v3 
2832
29-       - name : Log into registry ${{ env.REGISTRY }} 
33+       - name : Login to GitHub Container Registry 
3034        if : github.event_name != 'pull_request' 
3135        uses : docker/login-action@v3 
3236        with :
33-           registry : ${{ env.REGISTRY }} 
37+           registry : ghcr.io 
3438          username : ${{ github.actor }} 
3539          password : ${{ secrets.GITHUB_TOKEN }} 
3640
@@ -40,20 +44,24 @@ jobs:
4044        with :
4145          images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 
4246
43-       - name : Build and push Docker image (postgres:14) 
44-         uses :  docker/build-push-action@v5 
45-         with : 
46-           push :  ${{ github.event_name != 'pull_request' }}  
47-           platforms :  linux/amd64,linux/arm64 
48-           file :  14/Dockerfile 
49-           tags :  ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:14 
50-           labels :  ${{ steps.meta.outputs.labels }} 
47+       - name : Set latest tag 
48+         run :  | 
49+           echo "Setting tags..."  
50+           if [ " ${{ matrix.pg_version }}" = "17" ]; then  
51+             echo "LATEST_TAG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_ENV  
52+           else  
53+             echo "LATEST_TAG=" >> $GITHUB_ENV  
54+           fi  
5155
52-       - name : Build and push Docker image (postgres:16 ) 
53-         uses : docker/build-push-action@v5  
56+ name : Build and push Docker image (postgres:${{ matrix.pg_version }} ) 
57+         uses : docker/build-push-action@v6  
5458        with :
5559          push : ${{ github.event_name != 'pull_request' }} 
60+           tags : | 
61+             ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.pg_version }} 
62+             ${{ env.LATEST_TAG }} 
5663platforms : linux/amd64,linux/arm64 
57-           file : 16/Dockerfile 
58-           tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:16,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest 
64+           file : ${{ matrix.pg_version }}/Dockerfile 
65+           cache-from : type=gha 
66+           cache-to : type=gha,mode=max 
5967          labels : ${{ steps.meta.outputs.labels }} 
0 commit comments