Early successful termination of job

I have a schedule trigger, and when it runs I want to check if I really need to do the whole job, or if I can terminate it early, with a success status.

I plan to do this by using the GITHUB_SHA to check an external service if I already have the result I need.

If I do (no change happened since the previous day execution) I want to terminate the job, but not as a fail.

3 Likes

I would also like this (as a way to simulate a paths option for jobs – bail if no paths match)

I believe you could use one job that calls your external storage, performs the checking and returns either true or false. Then your actual jobs depends on the setup job.

name: My workflows
on:
  schedule:
    - cron: '*/15 * * * *'
jobs:
  myjob:
    steps:
      setup:
        runs: curl -LSsf https://external-service.org

  otherjob:
    needs:
      - myjob
    steps:
    # ...

When the curl command fails the step fails. Maybe you need to mark the job as failed manually, never tried that before.

I don’t want a failed job, but I used a similar aproach. I created an action which have a boolean output, and the use this output at other steps.

https://github.com/tuler/s3-check-action