2222
2323jobs :
2424  timestamp :
25+     if : (github.event_name != 'schedule' || github.event.repo.name == 'discourse/discourse_docker') 
2526    runs-on : ubuntu-latest 
2627    outputs :
2728      timestamp : ${{ steps.timestamp.outputs.timestamp }} 
3334          echo "timestamp=$timestamp" >> $GITHUB_OUTPUT 
3435
3536base :
37+     if : (github.event_name != 'schedule' || github.event.repo.name == 'discourse/discourse_docker') 
3638    #  `unbuntu-22.04-8core` for arch amd64 non-scheduled builds
3739    #  `unbuntu-22.04` for arch amd64 scheduled builds
3840    #  `unbuntu-22.04-8core-arm` for arch arm64 non-scheduled builds
@@ -103,8 +105,25 @@ jobs:
103105        run : | 
104106          docker images discourse/base 
105107
108+ name : Print compressed summary 
109+         if : github.event_name == 'pull_request' && matrix.arch == 'amd64' 
110+         run : | 
111+           # Push to local repo to compare sizes 
112+           docker run --quiet -d --rm -p 5002:5000 registry:2 
113+           sleep 5 
114+           docker tag discourse/base:2.0.${{ env.TIMESTAMP }}-slim-${{ matrix.arch }} localhost:5002/base:2.0.${{ env.TIMESTAMP }}-slim-${{ matrix.arch }} 
115+           docker tag discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} localhost:5002/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} 
116+           docker push --quiet localhost:5002/base:2.0.${{ env.TIMESTAMP }}-slim-${{ matrix.arch }} 
117+           docker push --quiet localhost:5002/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} 
118+           # multiarch manifest is an array of schemas - [0] is amd64, [1] is arch64: Compare amd64. 
119+           CURRENT_SLIM=$(docker manifest inspect -v discourse/base:slim | jq -r '.[0].SchemaV2Manifest.layers[] | .size / 1024 / 1024 | .*100 | round/100' | awk '{print $0; sum+= $0}; END {print sum}' | tail -n 1) 
120+           CURRENT_RELEASE=$(docker manifest inspect -v discourse/base:release | jq -r '.[0].SchemaV2Manifest.layers[] | .size / 1024 / 1024 | .*100 | round/100' | awk '{print $0; sum+= $0}; END {print sum}' | tail -n 1) 
121+           NEW_SLIM=$(docker manifest inspect -v --insecure localhost:5002/base:2.0.${{ env.TIMESTAMP }}-slim-${{ matrix.arch }} |  jq -r '.SchemaV2Manifest.layers[] | .size / 1024 / 1024 | .*100 | round/100' | awk '{print $0; sum+= $0}; END {print sum}' | tail -n 1) 
122+           NEW_RELEASE=$(docker manifest inspect -v --insecure localhost:5002/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} | jq -r '.SchemaV2Manifest.layers[] | .size / 1024 / 1024 | .*100 | round/100' | awk '{print $0; sum+= $0}; END {print sum}' | tail -n 1) 
123+           echo "current slim: ${CURRENT_SLIM} release: ${CURRENT_RELEASE}. new slim: ${NEW_SLIM} release: ${NEW_RELEASE}" 
124+ 
106125name : push to dockerhub 
107-         if : github.ref == 'refs/heads/main' 
126+         if : github.ref == 'refs/heads/main' && github.event.repo.name == 'discourse/discourse_docker'  
108127        env :
109128          DOCKERHUB_PASSWORD : ${{ secrets.DOCKERHUB_PASSWORD }} 
110129        run : | 
@@ -115,7 +134,7 @@ jobs:
115134          docker push discourse/discourse_dev:${{ env.TIMESTAMP }}-${{ matrix.arch }} 
116135
117136name : Push discourse/base:aarch64 image for backwards compatibility 
118-         if : (github.ref == 'refs/heads/main') && (matrix.arch == 'arm64') 
137+         if : (github.ref == 'refs/heads/main') && (matrix.arch == 'arm64') && (github.event.repo.name == 'discourse/discourse_docker')  
119138        run : | 
120139          docker tag discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} discourse/base:aarch64 
121140          docker push discourse/base:aarch64 
@@ -125,7 +144,7 @@ jobs:
125144    needs : [base, timestamp] 
126145    env :
127146      TIMESTAMP : ${{ needs.timestamp.outputs.timestamp }} 
128-     if : github.ref == 'refs/heads/main' 
147+     if : github.ref == 'refs/heads/main' && github.event.repo.name == 'discourse/discourse_docker'  
129148    steps :
130149      - name : create and push multiarch manifests 
131150        run : | 
@@ -212,7 +231,7 @@ jobs:
212231        run : | 
213232          docker images discourse/discourse_test 
214233name : push to dockerhub 
215-         if : success() && (github.ref == 'refs/heads/main') 
234+         if : success() && (github.ref == 'refs/heads/main') && (github.event.repo.name == 'discourse/discourse_docker')  
216235        env :
217236          DOCKERHUB_PASSWORD : ${{ secrets.DOCKERHUB_PASSWORD }} 
218237        run : | 
0 commit comments