Skip to content

Instantly share code, notes, and snippets.

@Guthers
Last active November 12, 2024 07:39
Show Gist options
  • Save Guthers/0a9101647ef72abe03aa84ca75fec4e3 to your computer and use it in GitHub Desktop.
Save Guthers/0a9101647ef72abe03aa84ca75fec4e3 to your computer and use it in GitHub Desktop.
This Gist aims to demonstrate having a github action where a job (job3) depends on a skippable job (job2). Play with the run/if conditions on job2 to check the three important outcomes, success, failure, skipped.
name: Github Action skippable job example
on:
pull_request:
types: [synchronize]
jobs:
job1:
name: Step 1
runs-on: ubuntu-latest
steps:
- name: Step1
run: echo "Step1"
job2:
name: Skippable Step
if: ${{1 == 1}}
needs: [job1]
runs-on: ubuntu-latest
steps:
- name: Step2
run: exit 1
job3:
name: Require Job 2 to be skipped or succeeded
needs: [job2]
# https://stackoverflow.com/a/77066140
if: always() && !failure() && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Step3
run: echo "Step3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment