@@ -70,10 +70,11 @@ runs:
7070 - name : Precheck local image exists
7171 id : precheck
7272 shell : bash
73+ env :
74+ INPUT_IMAGE : ${{ inputs.image }}
7375 run : |
7476 set +e
75- IMAGE="${{ inputs.image }}"
76- docker image inspect "${IMAGE}" >/dev/null 2>&1
77+ docker image inspect "${INPUT_IMAGE}" >/dev/null 2>&1
7778 rc=$?
7879 if [ $rc -eq 0 ]; then
7980 echo "image_exists=true" >> "$GITHUB_OUTPUT"
@@ -96,13 +97,14 @@ runs:
9697 id : grype
9798 if : ${{ steps.precheck.outputs.image_exists == 'true' }}
9899 shell : bash
100+ env :
101+ IMAGE : ${{ inputs.image }}
102+ REPORT_JSON : ${{ inputs.report-json }}
103+ REPORT_SARIF : ${{ inputs.report-sarif }}
104+ FAIL_ON : ${{ inputs.fail-on }}
105+ GRYPE_IMAGE : ${{ inputs.grype-image }}
99106 run : |
100107 set +e
101- IMAGE="${{ inputs.image }}"
102- REPORT_JSON="${{ inputs.report-json }}"
103- REPORT_SARIF="${{ inputs.report-sarif }}"
104- FAIL_ON="${{ inputs.fail-on }}"
105- GRYPE_IMAGE="${{ inputs.grype-image }}"
106108
107109 echo "Pulling Grype scanner image..."
108110 docker pull "${GRYPE_IMAGE}" >/dev/null 2>&1
@@ -147,58 +149,67 @@ runs:
147149 - name : Write scan summary
148150 if : ${{ inputs.write-summary == 'true' }}
149151 shell : bash
152+ env :
153+ INPUT_IMAGE : ${{ inputs.image }}
154+ INPUT_ARTIFACT_NAME : ${{ inputs.artifact-name }}
155+ INPUT_REPORT_JSON : ${{ inputs.report-json }}
150156 run : |
151157 set -euo pipefail
152158 echo "### 🔍 Container Scan (SBOM + Grype)" >> "$GITHUB_STEP_SUMMARY"
153159 echo "" >> "$GITHUB_STEP_SUMMARY"
154- echo "- Image: \`${{ inputs.image } }\`" >> "$GITHUB_STEP_SUMMARY"
155- echo "- Reports artifact: \`${{ inputs.artifact-name } }\` (sarif + json)" >> "$GITHUB_STEP_SUMMARY"
160+ echo "- Image: \`${INPUT_IMAGE }\`" >> "$GITHUB_STEP_SUMMARY"
161+ echo "- Reports artifact: \`${INPUT_ARTIFACT_NAME }\` (sarif + json)" >> "$GITHUB_STEP_SUMMARY"
156162
157- if [ -f "${{ inputs.report-json } }" ]; then
158- python3 "$GITHUB_ACTION_PATH/grype_summary.py" --json "${{ inputs.report-json } }" --max-top 10 >> "$GITHUB_STEP_SUMMARY" || true
163+ if [ -f "${INPUT_REPORT_JSON }" ]; then
164+ python3 "$GITHUB_ACTION_PATH/grype_summary.py" --json "${INPUT_REPORT_JSON }" --max-top 10 >> "$GITHUB_STEP_SUMMARY" || true
159165 fi
160166
161167 - name : Finalize status/outputs
162168 id : final
163169 if : always()
164170 shell : bash
171+ env :
172+ IMAGE_EXISTS : ${{ steps.precheck.outputs.image_exists }}
173+ SBOM_OUTCOME : ${{ steps.sbom.outcome }}
174+ GRYPE_STATUS : ${{ steps.grype.outputs.status }}
175+ GRYPE_EXIT : ${{ steps.grype.outputs.exit_code }}
176+ INPUT_GENERATE_SBOM : ${{ inputs.generate-sbom }}
177+ INPUT_FAIL_ON : ${{ inputs.fail-on }}
178+ INPUT_REPORT_JSON : ${{ inputs.report-json }}
179+ INPUT_REPORT_SARIF : ${{ inputs.report-sarif }}
180+ INPUT_FAIL_BUILD : ${{ inputs.fail-build }}
165181 run : |
166182 set -euo pipefail
167183
168- IMAGE_EXISTS="${{ steps.precheck.outputs.image_exists }}"
169- SBOM_OUTCOME="${{ steps.sbom.outcome }}"
170- GRYPE_STATUS="${{ steps.grype.outputs.status }}"
171- GRYPE_EXIT="${{ steps.grype.outputs.exit_code }}"
172-
173184 status="ok"
174185 detail="ok"
175186
176187 if [ "${IMAGE_EXISTS}" != "true" ]; then
177188 status="image_not_found"
178189 detail="local docker image not found"
179- elif [ "${{ inputs.generate-sbom } }" = "true" ] && [ "${SBOM_OUTCOME}" != "success" ]; then
190+ elif [ "${INPUT_GENERATE_SBOM }" = "true" ] && [ "${SBOM_OUTCOME}" != "success" ]; then
180191 status="sbom_failed"
181192 detail="sbom-action failed"
182193 elif [ -z "${GRYPE_STATUS}" ]; then
183194 status="grype_unknown"
184195 detail="grype step did not produce status"
185196 elif [ "${GRYPE_STATUS}" = "ok" ]; then
186197 status="ok"
187- detail="no vulnerabilities at/above fail-on=${{ inputs.fail-on } }"
198+ detail="no vulnerabilities at/above fail-on=${INPUT_FAIL_ON }"
188199 elif [ "${GRYPE_STATUS}" = "high_or_error" ]; then
189200 status="high_or_error"
190- detail="grype exit_code=${GRYPE_EXIT} (fail-on=${{ inputs.fail-on } })"
201+ detail="grype exit_code=${GRYPE_EXIT} (fail-on=${INPUT_FAIL_ON })"
191202 else
192203 status="${GRYPE_STATUS}"
193204 detail="grype exit_code=${GRYPE_EXIT}"
194205 fi
195206
196207 echo "status=${status}" >> "$GITHUB_OUTPUT"
197208 echo "detail=${detail}" >> "$GITHUB_OUTPUT"
198- echo "report_json=${{ inputs.report-json } }" >> "$GITHUB_OUTPUT"
199- echo "report_sarif=${{ inputs.report-sarif } }" >> "$GITHUB_OUTPUT"
209+ echo "report_json=${INPUT_REPORT_JSON }" >> "$GITHUB_OUTPUT"
210+ echo "report_sarif=${INPUT_REPORT_SARIF }" >> "$GITHUB_OUTPUT"
200211
201- if [ "${{ inputs.fail-build } }" = "true" ] && [ "${status}" != "ok" ]; then
212+ if [ "${INPUT_FAIL_BUILD }" = "true" ] && [ "${status}" != "ok" ]; then
202213 echo "Failing build due to status=${status}: ${detail}" 1>&2
203214 exit 1
204215 fi
0 commit comments