Skip to content

Demo 9 - Handling Failures #5

Demo 9 - Handling Failures

Demo 9 - Handling Failures #5

# This is a basic workflow to help you get started with Actions
name: Demo 9 - Handling Failures
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
workflow_dispatch:
# We have multiple jobs here and the first job is set to fail
# Multiple scenarios exist:
# 1. How to still run Job 2 when there is no dependency between jobs
# 2. How to still run Job 2 when there is a dependency between jobs
jobs:
# This workflow contains a single job called "build"
Job1:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- run: exit 0
Job2:
runs-on: ubuntu-latest
needs: Job1
if: ${{ failure() }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- run: echo "still running"
if: ${{ failure() }}
#- run: exit 1
- run: echo "NOT running?"
if: ${{ success() }}