From d2bfd54cdbe25c40c4e53aa7359d375f534ecc49 Mon Sep 17 00:00:00 2001 From: jhsuss Date: Mon, 21 Oct 2024 11:14:47 +0100 Subject: [PATCH] w secret --- .github/workflows/run-pipeline.yml | 4 ++++ src/fetch.py | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run-pipeline.yml b/.github/workflows/run-pipeline.yml index d7d3e2d..e9d6132 100644 --- a/.github/workflows/run-pipeline.yml +++ b/.github/workflows/run-pipeline.yml @@ -27,6 +27,10 @@ jobs: run: pipenv install --ignore-pipfile - name: Run python code + env: # Set the secret as an input + FUTURE_FIRST: ${{ secrets.FUTURE_FIRST }} + # FIRST_NAME: Joel + # LAST_NAME: Suss run: pipenv run start - uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/src/fetch.py b/src/fetch.py index af17082..bcd949b 100644 --- a/src/fetch.py +++ b/src/fetch.py @@ -1,21 +1,23 @@ import requests +import os def get_data(): - # res = requests.get("https://dummyjson.com/products?limit=10&select=id,title,brand,price") - # data = res.json().get('products') - # print(f"Loaded {len(data)} rows of JSON from the API") - # return data - # r = requests.get("https://www.goodjudgment.io/futurefirst/api/forecasts", headers = {"Authorization": "Bearer 8030152dfa8a9930ec132f831500dd54c55c1889"}) - r = requests.get("https://goodjudgment.io/futurefirst/api/fcsv", headers = {"Authorization": "Bearer 8030152dfa8a9930ec132f831500dd54c55c1889"}) + + # Retrieve the environment variable "key" + key = os.getenv("FUTURE_FIRST") - #r.json() - #r.json()["status"] + # r = requests.get("https://goodjudgment.io/futurefirst/api/fcsv", headers = {"Authorization": "Bearer 8030152dfa8a9930ec132f831500dd54c55c1889"}) + + r = requests.get( + "https://goodjudgment.io/futurefirst/api/fcsv", + headers = {"Authorization": "Bearer " + key} + ) + data = r.json()["data"] print(f"Loaded {len(data)} rows of CSV from the API") return data - #res = r.json() - +