diff --git a/.github/workflows/tw165.yml b/.github/workflows/tw165.yml index 54b9c9b..97d782f 100644 --- a/.github/workflows/tw165.yml +++ b/.github/workflows/tw165.yml @@ -16,7 +16,9 @@ jobs: cache: 'pip' # caching pip dependencies - run: pip install -r AutoBuild/requirements.txt && python AutoBuild/tw_165.py env: - tw165: ${{ vars.TW165 }} + tw165json: ${{ vars.TW165JSON }} + tw165csv: ${{ vars.TW165CSV }} + auth: ${{ secrets.AUTH }} - name: push uses: github-actions-x/commit@v2.9 with: diff --git a/AutoBuild/tw_165.py b/AutoBuild/tw_165.py index cdec090..69f2307 100644 --- a/AutoBuild/tw_165.py +++ b/AutoBuild/tw_165.py @@ -1,4 +1,5 @@ import requests +from requests.auth import HTTPBasicAuth from json.decoder import JSONDecodeError import logging import os @@ -10,11 +11,18 @@ logger = logging.getLogger(__name__) def main(): - url = os.getenv('tw165', None) + auth = os.getenv('auth', None) + url = os.getenv('tw165json', None) if not url: logger.critical('URL NOT SET') return - r = requests.get(url) + if not auth: + logger.critical('AUTH NOT SET') + return + + user, passwd = auth.split(':') + basic = HTTPBasicAuth(user, passwd) + r = requests.get(url, auth=basic) if r.status_code != 200: logger.critical('Fetch Data Err') return