Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 4

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 Replies
Pilot Lvl 1
Message 2 of 4

Re: Early successful termination of job

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

Pilot Lvl 1
Message 3 of 4

Re: Early successful termination of job

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.

Highlighted
Copilot Lvl 3
Message 4 of 4

Re: Early successful termination of job

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