Github Actions: Run Python Script On Approval Pull Request
Description:
This post will build on a previous post with Github Actions in which we will run a python script instead of a bash script on Pull Requests. It is also built on the publish new branch post so give that a read as well if you haven’t already.
To Resolve:
-
So the first thing you will need to do is go to your repo inside Github Web UI and add the secret
API_MGMT_KEYwhich matches yourOcp-Apim-Subscription-Keyvalue for the header you will pass to your API Mgmt endpoint. -
Next, go to my Github and copy all the files under
example-run-python-script-on-approval(from the.githubfolder down)- Make sure you have the
workflowandscriptfolders with their associated files. - Github Actions work by looking for a
.githubfolder at the root of your repo and then looking at the structure downwards.
- Make sure you have the
-
The way this works is that when you do a pull request where you are merging from your
dev_gerrybranch to branchtesting, it will perform one of two actions:- If the approver approves and the branches are merged, a script
api-testing-branch.pyis fired. - Likewise on branch
maina scriptapi-main-branch.pyis fired. - On the other hand, if the approver rejects, a line of text is written to the output stream that you can see on the Functions output in Github Actions screen.
- If the approver approves and the branches are merged, a script
Comments