title: Running a GitHub Actions step only if previous step has run
body: <p>I've set up a workflow in GitHub actions to run my tests and create an artifact of the test coverage. The stripped down version of my YAML file looks like this:</p>
  
  <pre><code>name: Build
  
  on: [pull_request]
  
  jobs:
    build:
      runs-on: ubuntu-latest
  
      steps:
        # Other steps here
  
        - name: Build app
        - name: Run tests
        - name: Create artifact of test coverage
  
        # Other steps here
  </code></pre>
  
  <p>The problem is that the artifact does not get created when the tests fail.</p>
  
  <p>I figured out about <code>if: always()</code> condition the from the <a href="https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#job-status-check-functions" rel="noreferrer">docs</a>, but this will also cause this step to run when my <code>Build app</code> step fails. I don't want that to happen because there is nothing to archive in that case.</p>
  
  <p>How can I only run this step if the previous step has run (either succeeded or failed)?</p>