nerdexam
MicrosoftMicrosoft

GH-200 · Question #69

GH-200 Question #69: Real Exam Question with Answer & Explanation

The correct answer is A: jobs:. {"question_number": 7, "correct_answer": "A", "explanation": "To conditionally run a job only on a specific branch, you use the if: conditional at the job level with a GitHub context expression referencing github.ref. The correct syntax is if: github.ref == 'refs/heads/feature-br

Author and Maintain Workflows

Question

You are a DevOps engineer working on deployment workflows. You need to execute the deploy job only if the current branch name is feature-branch. Which code snippet will help you to implement the conditional execution of the job?

Options

  • Ajobs:
  • Bjobs:
  • Cjobs:
  • Djobs:

Explanation

{"question_number": 7, "correct_answer": "A", "explanation": "To conditionally run a job only on a specific branch, you use the if: conditional at the job level with a GitHub context expression referencing github.ref. The correct syntax is if: github.ref == 'refs/heads/feature-branch'. GitHub stores the full ref path (e.g., refs/heads/feature-branch), so the comparison must include that prefix. Alternatively, github.ref_name == 'feature-branch' can also work. The other options (B, C, D) likely contain incorrect context variable names or comparison syntax, which would cause the condition to never evaluate correctly.", "generated_by": "claude-sonnet", "llm_judge_score": 4}

Topics

#GitHub Actions#Conditional execution#Workflow jobs#Branch conditions

Community Discussion

No community discussion yet for this question.

Full GH-200 PracticeBrowse All GH-200 Questions