2323 description : " Human-readable image title for OCI labels (e.g., AFM Ballerina Interpreter)"
2424 required : true
2525 type : string
26+ build_slim :
27+ description : " Whether to build and push a slim image variant"
28+ required : false
29+ default : false
30+ type : boolean
2631
2732jobs :
2833 docker :
@@ -56,21 +61,24 @@ jobs:
5661 run : |
5762 # GHCR requires lowercase repository names
5863 OWNER_LOWER=$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')
59- FULL_IMAGE="ghcr.io/$OWNER_LOWER/$IMAGE_NAME"
60- TAGS="$FULL_IMAGE:v$VERSION"
61- if [ "$UPDATE_LATEST" = "true" ]; then
62- TAGS="$TAGS,$FULL_IMAGE:latest"
63- fi
64- echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
65- echo "FULL_IMAGE=$FULL_IMAGE" >> $GITHUB_OUTPUT
64+ BASE_IMAGE="ghcr.io/$OWNER_LOWER/$IMAGE_NAME"
65+ TAGS_FULL="$BASE_IMAGE:v$VERSION"
66+ [ "$UPDATE_LATEST" = "true" ] && TAGS_FULL="$TAGS_FULL,$BASE_IMAGE:latest"
67+ echo "TAGS_FULL=$TAGS_FULL" >> $GITHUB_OUTPUT
6668
67- - name : Build and push Docker image
69+ TAGS_SLIM="$BASE_IMAGE:v$VERSION-slim"
70+ [ "$UPDATE_LATEST" = "true" ] && TAGS_SLIM="$TAGS_SLIM,$BASE_IMAGE:slim"
71+ echo "TAGS_SLIM=$TAGS_SLIM" >> $GITHUB_OUTPUT
72+ echo "BASE_IMAGE=$BASE_IMAGE" >> $GITHUB_OUTPUT
73+
74+ - name : Build and push full image
6875 uses : docker/build-push-action@v5
6976 with :
7077 context : ${{ inputs.context }}
7178 push : true
7279 platforms : linux/amd64,linux/arm64
73- tags : ${{ steps.docker-tags.outputs.TAGS }}
80+ build-args : VARIANT=full
81+ tags : ${{ steps.docker-tags.outputs.TAGS_FULL }}
7482 labels : |
7583 org.opencontainers.image.source=https://github.com/${{ github.repository }}
7684 org.opencontainers.image.version=${{ inputs.version }}
@@ -81,18 +89,56 @@ jobs:
8189 index:org.opencontainers.image.source=https://github.com/${{ github.repository }}
8290 index:org.opencontainers.image.licenses=Apache-2.0
8391
84- - name : Scan Docker image for vulnerabilities
92+ - name : Build and push slim image
93+ if : ${{ inputs.build_slim }}
94+ uses : docker/build-push-action@v5
95+ with :
96+ context : ${{ inputs.context }}
97+ push : true
98+ platforms : linux/amd64,linux/arm64
99+ build-args : VARIANT=slim
100+ tags : ${{ steps.docker-tags.outputs.TAGS_SLIM }}
101+ labels : |
102+ org.opencontainers.image.source=https://github.com/${{ github.repository }}
103+ org.opencontainers.image.version=${{ inputs.version }}
104+ org.opencontainers.image.revision=${{ github.sha }}
105+ org.opencontainers.image.title=${{ inputs.image_title }} (Slim)
106+ org.opencontainers.image.licenses=Apache-2.0
107+ annotations : |
108+ index:org.opencontainers.image.source=https://github.com/${{ github.repository }}
109+ index:org.opencontainers.image.licenses=Apache-2.0
110+
111+ - name : Scan full Docker image for vulnerabilities
85112 uses : aquasecurity/trivy-action@0.34.0
86113 with :
87- image-ref : ${{ steps.docker-tags.outputs.FULL_IMAGE }}:v${{ inputs.version }}
114+ image-ref : ${{ steps.docker-tags.outputs.BASE_IMAGE }}:v${{ inputs.version }}
88115 format : " sarif"
89- output : " trivy-results.sarif"
116+ output : " trivy-results-full .sarif"
90117 severity : " CRITICAL,HIGH"
91118 limit-severities-for-sarif : true
92119 exit-code : " 1"
93120
94- - name : Upload Trivy scan results to GitHub Security tab
121+ - name : Upload full image Trivy scan results to GitHub Security tab
95122 uses : github/codeql-action/upload-sarif@v4
96123 if : always()
97124 with :
98- sarif_file : " trivy-results.sarif"
125+ sarif_file : " trivy-results-full.sarif"
126+ category : " trivy-full-${{ inputs.image_name }}"
127+
128+ - name : Scan slim Docker image for vulnerabilities
129+ if : ${{ always() && inputs.build_slim }}
130+ uses : aquasecurity/trivy-action@0.34.0
131+ with :
132+ image-ref : ${{ steps.docker-tags.outputs.BASE_IMAGE }}:v${{ inputs.version }}-slim
133+ format : " sarif"
134+ output : " trivy-results-slim.sarif"
135+ severity : " CRITICAL,HIGH"
136+ limit-severities-for-sarif : true
137+ exit-code : " 1"
138+
139+ - name : Upload slim image Trivy scan results to GitHub Security tab
140+ uses : github/codeql-action/upload-sarif@v4
141+ if : ${{ always() && inputs.build_slim }}
142+ with :
143+ sarif_file : " trivy-results-slim.sarif"
144+ category : " trivy-slim-${{ inputs.image_name }}"
0 commit comments