1919
2020env :
2121 REGISTRY : ghcr.io
22- IMAGE_NAME : ${{ github.repository }}
22+ BASE_IMAGE_NAME : ${{ github.repository }}
23+ IDE_IMAGE_NAME : ${{ github.repository_owner }}/my-ide
2324
2425jobs :
2526 build-and-push :
@@ -43,11 +44,11 @@ jobs:
4344 username : ${{ github.actor }}
4445 password : ${{ secrets.GITHUB_TOKEN }}
4546
46- - name : Extract metadata (tags, labels)
47- id : meta
47+ - name : Extract metadata for base image
48+ id : meta-base
4849 uses : docker/metadata-action@v5
4950 with :
50- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+ images : ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}
5152 tags : |
5253 type=ref,event=branch
5354 type=ref,event=pr
@@ -57,27 +58,40 @@ jobs:
5758 type=sha,prefix={{branch}}-
5859 type=raw,value=latest,enable={{is_default_branch}}
5960
60- - name : Build base image using Dockerfile
61+ - name : Extract metadata for IDE image
62+ id : meta-ide
63+ uses : docker/metadata-action@v5
64+ with :
65+ images : ${{ env.REGISTRY }}/${{ env.IDE_IMAGE_NAME }}
66+ tags : |
67+ type=ref,event=branch
68+ type=ref,event=pr
69+ type=semver,pattern={{version}}
70+ type=semver,pattern={{major}}.{{minor}}
71+ type=semver,pattern={{major}}
72+ type=sha,prefix={{branch}}-
73+ type=raw,value=latest,enable={{is_default_branch}}
74+
75+ - name : Build and push base image
6176 uses : docker/build-push-action@v6
6277 with :
6378 context : .
6479 file : ./Dockerfile
65- push : false
66- load : true
67- tags : base-image:latest
68- labels : ${{ steps.meta.outputs.labels }}
80+ push : ${{ github.event_name != 'pull_request' }}
81+ tags : ${{ steps.meta-base.outputs.tags }}
82+ labels : ${{ steps.meta-base.outputs.labels }}
6983 cache-from : type=gha
7084 cache-to : type=gha,mode=max
7185 platforms : linux/amd64
7286
73- - name : Build and push IDE image using Dockerfile.ide
87+ - name : Build and push IDE image
7488 uses : docker/build-push-action@v6
7589 with :
7690 context : .
7791 file : ./Dockerfile.ide
7892 push : ${{ github.event_name != 'pull_request' }}
79- tags : ${{ steps.meta.outputs.tags }}
80- labels : ${{ steps.meta.outputs.labels }}
93+ tags : ${{ steps.meta-ide .outputs.tags }}
94+ labels : ${{ steps.meta-ide .outputs.labels }}
8195 cache-from : type=gha
8296 cache-to : type=gha,mode=max
8397 platforms : linux/amd64
0 commit comments