<p>You can add</p>
<pre><code class="lang-auto">if: always()
</code></pre>
<p>to your step to have it run even if a previous step fails<br>
<a href="https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions">https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions</a></p>
<p>so for a single step it would look like this:</p>
<pre><code class="lang-auto">steps:
</code></pre>
<p>Or you can add it to a job:</p>
<pre><code class="lang-auto">jobs:
job1:
job2:
needs: job1
job3:
if: always()
needs: [job1, job2]
</code></pre>
<p>Additionally, as pointed out below, putting <code>always()</code> will cause the function to run even if the build is canceled. If you don’t want the function to run when you manually cancel a job, you can instead put:</p>
<pre><code class="lang-auto">if: success() || failure()
</code></pre>
<p>or</p>
<pre><code class="lang-auto">if: '!cancelled()'
</code></pre>
<p>(Quotes are needed so that <code>!cancelled()</code> is not interpreted as a YAML tag.)</p>
<p>Likewise, if you want to run a function ONLY when something has failed, you can put:</p>
<pre><code class="lang-auto">if: failure()
</code></pre>
<p>Also, as mentioned in the comments, if a status check function is not used in <code>if</code>, like</p>
<pre><code class="lang-auto">if: true
</code></pre>
<p>the result will (perhaps confusingly) behave like</p>
<pre><code class="lang-auto">if: success() && true
</code></pre>
<p>This is documented in <a href="https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions">Expressions - GitHub Docs</a>:</p>
<h2><a name="p-25162-status-check-functions-1" class="anchor" href="#p-25162-status-check-functions-1" aria-label="Heading link"></a>Status check functions</h2>
<p>You can use the following status check functions as expressions in if conditionals. A default status check of <code>success()</code> is applied unless you include one of these functions.</p>