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_KEY
which matches yourOcp-Apim-Subscription-Key
value 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.github
folder down)- Make sure you have the
workflow
andscript
folders with their associated files. - Github Actions work by looking for a
.github
folder 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_gerry
branch to branchtesting
, it will perform one of two actions:- If the approver approves and the branches are merged, a script
api-testing-branch.py
is fired. - Likewise on branch
main
a scriptapi-main-branch.py
is 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