I need help with a GitHub Actions workflow issue. I’m running automated tests and want to upload the test results as artifacts, but I’m having problems when tests fail.
My current setup works perfectly when tests pass - everything runs and artifacts get uploaded. However, when tests fail, the workflow stops and never reaches the artifact upload step.
I tried using continue-on-error: true which does let the workflow continue and upload artifacts, but then the entire job shows as successful even though the tests actually failed.
Is there a way to force artifact upload even after a step fails, but still have the job marked as failed?
Here’s my current workflow:
name: Build Pipeline
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
test-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Unit Tests
run: ./mvnw test
- name: Upload Test Reports
uses: actions/upload-artifact@v2
with:
name: test-reports
path: target/surefire-reports