Skip to content

[QUESTION] #145

@LuthiraPeiris

Description

@LuthiraPeiris

Question

How does conditional execution in GitHub Actions determine whether a step runs on a specific branch?

What have you tried?

I created a conditional workflow that runs a deploy step only when pushing to the main branch using:

if: github.ref == 'refs/heads/main'

I tested it by pushing to both develop and main branches and observed the different behavior.

Relevant Documentation

Link any relevant documentation you've read:

Code Example

  • name: Deploy (main only)
    if: github.ref == 'refs/heads/main'
    run: echo "Deploying to production..."
# Your code here

Environment

  • Node.js Version: [18.x]
  • Operating System: [Windows]
  • Browser: [Chrome]

Additional Context

This issue was created as part of Advanced Task 10 to demonstrate usage of issue templates.


Don't hesitate to ask! We're here to help! 🤝

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions