how to apply a if condition for the name of the branch we get using list of branches api in gitactions #40428
Unanswered
j-jagan
asked this question in
Apps, API and Webhooks
Replies: 1 comment
-
|
In principle, you need to parse the value you want out of the JSON response. Then you can store it in an environment variable or output. The minimal way to do JSON parsing is probably with However, mind that the response contains a list of branches. The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Show & Tell
Body
When we run this api for getting the list of branches for a repository in gitactions workflow:
curl
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer "
https://api.github.com/repos/OWNER/REPO/branches
It gives the result in the given format:
[
{
"name": "master",
"commit": {
"sha": "c5b97d5ae6c19d5c5df71a34c7fbeeda2479ccbc",
"url": "https://api.github.com/repos/octocat/Hello-World/commits/c5b97d5ae6c19d5c5df71a34c7fbeeda2479ccbc"
},
"protected": true,
"protection": {
"required_status_checks": {
"enforcement_level": "non_admins",
"contexts": [
"ci-test",
"linter"
]
}
},
"protection_url": "https://api.github.com/repos/octocat/hello-world/branches/master/protection"
}
]
so, from the result, we are getting the name of the branch , how to store that branch name in a variable in our workflow.
Beta Was this translation helpful? Give feedback.
All reactions