Skip to content

CICD-225 · Conditional artifact publishing ​

Encyclopedia · Advanced workflow orchestration · All snippets

Previous · CICD-224 · Next · CICD-226

1. Where it fits ​

  • Placement .github/workflows/ci.yml step.
  • Prerequisites authenticated GitHub CLI, approved target repositories, or Actions runner for YAML entries.
  • Platforms github-actions.

2. Copy the snippet ​

yaml
if: ${{ !cancelled() && steps.tests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
  name: failed-test-report
  path: reports/junit.xml
  if-no-files-found: warn

3. How it works ​

The reporting step reads a failed test's raw outcome and uploads only its generated report. The guard excludes cancellation and avoids replacing the failed job result.

4. Verify the result ​

Give the test step the tests ID and emit a report. An intentionally failed test run uploads its diagnostic XML.

Validation version-dependent (YAML parse). Status definitions.