Skip to content

Instantly share code, notes, and snippets.

@DSdatsme
Created January 25, 2023 11:04
Show Gist options
  • Save DSdatsme/9581da9ec9b714293fb09bc97de4b1a9 to your computer and use it in GitHub Desktop.
Save DSdatsme/9581da9ec9b714293fb09bc97de4b1a9 to your computer and use it in GitHub Desktop.
GitHub Actions Condition testing
name: Basic Testing
run-name: "Basic Testing"
on:
workflow_dispatch:
jobs:
demo-job-1:
runs-on: ubuntu-22.04 # NOTE: Hardcoding for stability
steps:
- name: Exit 1
run: exit 1
job-2:
name: "Testing"
if: ${{ always() }}
needs: ['demo-job-1' ]
runs-on: ubuntu-22.04 # NOTE: Hardcoding for stability
steps:
- uses: actions/checkout@v3
- name: Slack - Failure Message
if: failure()
run: echo Failure only
- name: Slack - Failure Combo
if: ${{ failure() || needs.demo-job-1.result != 'success' }}
run: echo Failure combo
- name: Slack - Success Message
if: success()
run: echo Success only
- name: Slack - Success Combo
if: ${{ success() && needs.demo-job-1.result == 'success' }}
run: echo Success combo
- name: Prev success status
if: needs.demo-job-1.result == 'success'
run: echo Success prev
- name: Prev failure status
if: needs.demo-job-1.result != 'success'
run: echo failure prev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment