Created
January 25, 2023 11:04
-
-
Save DSdatsme/9581da9ec9b714293fb09bc97de4b1a9 to your computer and use it in GitHub Desktop.
GitHub Actions Condition testing
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: 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