Ok jmakin - the first request to create the pull request returns a massive JSON object that looks like this:
Code:
{
"url": "https://api.github.com/repos/xxx/api-bl-donor_portal_bio_lambda/pulls/27",
"id": 326110,
"node_id": "MDExOlB1bGzI2OTc3MTEw",
"html_url": "https://github.com/xxx/api-bl-bio_lambda/pull/27",
"number": 27,
"state": "open",
"locked": false,
"title": "eee",
...
So I want to capture that and parse out the number 27, which is needed in the 2nd api call to actually merge the pull request.
Here's the best I got so far. I'm reading the response of the first api call into a variable, then egrep-ping it twice. It works but I'm guessing there's a cleaner way?
Code:
pull_request_num=`echo "$api_response" | egrep '"number": [1-9]+,' | egrep -o '[1-9]+'`
Is there some way to get a value out of the regex w/o having to call egrep twice? In normal regex world you could put parens around the part you want to capture, like this: ([1-9]+). And then somehow that's output along with the regex result. I tried that but no luck.
Well I spoke to soon. I just assumed I could replace echo with a variable. Not working yet.
Ok fixed it - I had to leave the echo in and add backticks.
Last edited by suzzer99; 10-14-2019 at 06:00 PM.