Last active
November 12, 2024 07:39
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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