I have a custom GitHub action that encapsulates a linter using a Dockerfile. On push I want to verify that the linter works correctly, that is it should succeed on correct input and fail on incorrect input:
.github/workflows/test-action.yml
name: Test Action
on:
workflow_dispatch:
push:
branches:
- master
jobs:
test-correct:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Lint correct input
uses: ./
with:
file: should-succeed.ex
test-incorrect:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Lint incorrect input
uses: ./
with:
file: should-fail.ex
However on GitHub under e.g. https://github.com/myorg/myrepo/actions/runs/123456789 this will of course now color the successful job as green and the unsuccessful job as red. How can I tell GitHub to reverse the color so that a fail results in success and success results in failure?
Edit: I tried the following but it does not work, because then if: failure()
will not trigger:
[...]
- name: Lint incorrect input
uses: ./
continue-on-error: true
with:
file: should-fail.ex
- if: failure()
run: true
- if: success()
run: false
On the other hand if I remove the continue-on-error: true
line, then it will not work either, because the whole job will be counted as failed even if I return true.