-
I’d like to make a job or step (either would work for me) conditional in our workflow, and have it validate the current branch is “master”. Is there something we can reference in the |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
You can do a conditional statement using this:
|
Beta Was this translation helpful? Give feedback.
-
How did you know the value of |
Beta Was this translation helpful? Give feedback.
-
https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#github-context “ref” is a term of art in git (and thus github, it’s a common encounter in the API): https://git-scm.com/book/en/v2/Git-Internals-Git-References |
Beta Was this translation helpful? Give feedback.
-
You can print the value to verify:
|
Beta Was this translation helpful? Give feedback.
-
if: github.ref == ‘refs/heads/integration’ && github.event_name == ‘push’ You can this command and replace whatever branch or event you want to run for. |
Beta Was this translation helpful? Give feedback.
-
To archive the same with multiple branches and for less boilerplate, use the
More information: https://stackoverflow.com/a/62419599/2574719 |
Beta Was this translation helpful? Give feedback.
-
Include this in yout workflow.
|
Beta Was this translation helpful? Give feedback.
-
This approach may lead to unexpected results as it will also match when the branch name is refs/heads/prod or any substring of |
Beta Was this translation helpful? Give feedback.
-
I have another question. Someone suggest or tell me an idea. We have two repositories.
From the Application code branch, we call another repo's build template. My question is, from this yaml if it is a feature branch deployed in DEV and if it is the main deploy PROD? How to write a condition for the cross-repo Yaml? Note: We cannot update the build and deploy template as it is used for other services. Any changes we should perform to our application Yaml Application code branch yaml:
|
Beta Was this translation helpful? Give feedback.
You can do a conditional statement using this: