...
A snippet of the GitHub Workflow file:
Code Block | ||
---|---|---|
| ||
name: RadBee-Sandbox Test on: workflow_dispatch: inputs: snapshots_web_request_url: description: 'Snapshots web request url' required: true type: string snapshots_apikey: description: 'Snapshots api key' required: true type: string permissions: contents: read env: PYTHON_VERSION: '3.11' SNAPSHOTS_WEB_REQUEST_URL: ${{ inputs.snapshots_web_request_url }} SNAPSHOTS_APIKEY: ${{ inputs.snapshots_apikey }} jobs: build: runs-on: macos-latest steps: - uses: actions/checkout@v3 - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | pip install requests python -m pip install --upgrade pip python tests/take_snapshot.py |
...
And this is the snippet of the Python program:
Code Block | ||
---|---|---|
| ||
import requests import os def take_snapshot(): print("Start taking snapshot...") url = os.environ["SNAPSHOTS_WEB_REQUEST_URL"] headers = {"jira-snapshots-api-key": os.environ["SNAPSHOTS_APIKEY"]} response = requests.post(url, headers=headers) if response.status_code == 200: print("Snapshot was triggered successfully!") else: print(f"Error on taking snapshot: {response.status_code}") # run if __name__ == "__main__": take_snapshot() |
...