Skip to content

Trying to rescue a condition when previous steps are not run due to the if statement #25548

Answered by weide-zhou
y4m4p asked this question in Actions
Discussion options

You must be logged in to vote

The job status check functions ‘success(), failure()…’ only check the previous step status in the job. As a workaround, please set the ‘outputs’ for the 1st step, and check the value with ‘if’ in the behind steps. Code sample as below:

jobs:
  my-job:
    name: Something something
    runs-on: ubuntu-latest
    steps:
      - name: set output
        id: step1
        run: |
          echo ::set-output name=status::failure
        continue-on-error: true
  - name: Notify slack when success
    if: steps.step1.outputs.status == 'success'
    run: |
      echo "Success!"
  - name: Notify slack when it not run
    if: steps.step1.outputs.status != 'success'
    run: |
      echo "Something w…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants