Skip to main content
InterviewHubPRO
Section Overview
Q8

Question 8 of 50

Part 1: CI/CD Fundamentals & GitHub Actions Core (Junior / Entry-Level)

16%
CI/CD & GitHub Actions (50 Qs)•Part 1: CI/CD Fundamentals & GitHub Actions Core (Junior / Entry-Level)

How do conditional execution and status checks work?

junior LevelMost AskedCode ExampleState ManagementCI/CD & DevOps

In Simple Words: The if: keyword evaluates boolean expressions to skip or execute specific steps or entire jobs.

Status Check Functions:

  • success(): True if all previous steps succeeded (default).
  • always(): Forces the step to execute even if prior steps failed or were cancelled (vital for cleanup or sending Slack notifications).
  • failure(): Executes only if a preceding step in the job failed.
  • cancelled(): Executes only if the workflow was aborted.
yaml
- name: Send Slack Notification on Failure
  if: failure()
  uses: slackapi/slack-github-action@v1.26.0
  with:
    payload: '{"text":"❌ Build failed on branch ${{ github.ref_name }}"}'