I want to get an API call response inside GitHub Actions for example:
url = https://api.blabla.com/endpoint
response = requests.get(url)
print('response =', response)
I want to find a way to run this code inside GitHub Actions without need for any outside server just change the location locally inside the GitHub or YAML file if possible.
Yes, it's possible. When you run the CI in the GitHub actions, it use GitHub pods which connected to external service. So you can send the request into the external server and get the response from them. Here is simple code of yaml file.
name: API
on:
push:
branches:
-main
jobs:
api_request:
-name: check out repo
uses: actions/checkout@2
-name: set up python
uses: actions/setup-python@v2
with:
python-version: '3.9'
-name: install requirements
run: |
pip install requests
-name: Send Request to API
run: |
python -c "import requests; url = 'https://api.blabla.com/endpoint';response = requests.get(url); print('response =', response.text)"
You can think GitHub action that runs on server as a simple node of network.