til: github-actions_continue-on-error.md
This data as json
| path | topic | title | url | body | html | shot | created | created_utc | updated | updated_utc | shot_hash | slug |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| github-actions_continue-on-error.md | github-actions | Skipping a GitHub Actions step without failing | https://github.com/simonw/til/blob/main/github-actions/continue-on-error.md | I wanted to have a GitHub Action step run that might fail, but if it failed the rest of the steps should still execute and the overall run should be treated as a success. `continue-on-error: true` does exactly that: ```yaml - name: Download previous database run: curl --fail -o tils.db https://til.simonwillison.net/tils.db continue-on-error: true - name: Build database run: python build_database.py ``` [From this workflow](https://github.com/simonw/til/blob/7d799a24921f66e585b8a6b8756b7f8040c899df/.github/workflows/build.yml#L32-L36) I'm using `curl --fail` here which returns an error code if the file download files (without `--fail` it was writing out a two line error message to a file called `tils.db` which is not what I wanted). Then `continue-on-error: true` to keep on going even if the download failed. My `build_database.py` script updates the `tils.db` database file if it exists and creates it from scratch if it doesn't. | <p>I wanted to have a GitHub Action step run that might fail, but if it failed the rest of the steps should still execute and the overall run should be treated as a success.</p> <p><code>continue-on-error: true</code> does exactly that:</p> <div class="highlight highlight-source-yaml"><pre> - <span class="pl-ent">name</span>: <span class="pl-s">Download previous database</span> <span class="pl-ent">run</span>: <span class="pl-s">curl --fail -o tils.db https://til.simonwillison.net/tils.db</span> <span class="pl-ent">continue-on-error</span>: <span class="pl-c1">true</span> - <span class="pl-ent">name</span>: <span class="pl-s">Build database</span> <span class="pl-ent">run</span>: <span class="pl-s">python build_database.py</span></pre></div> <p><a href="https://github.com/simonw/til/blob/7d799a24921f66e585b8a6b8756b7f8040c899df/.github/workflows/build.yml#L32-L36">From this workflow</a></p> <p>I'm using <code>curl --fail</code> here which returns an error code if the file download files (without <code>--fail</code> it was writing out a two line error message to a file called <code>tils.db</code> which is not what I wanted). Then <code>continue-on-error: true</code> to keep on going even if the download failed.</p> <p>My <code>build_database.py</code> script updates the <code>tils.db</code> database file if it exists and creates it from scratch if it doesn't.</p> | <Binary: 64,343 bytes> | 2020-08-22T20:23:51-07:00 | 2020-08-23T03:23:51+00:00 | 2020-11-25T11:44:35-08:00 | 2020-11-25T19:44:35+00:00 | 30e610ad7045f1fa181666356c86d4a1 | continue-on-error |