From f3fb7210daa24c5206e9397aac9ea40fd0ba8642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B8=A2=E4=BD=8E=E5=90=B8?= Date: Mon, 10 Jul 2023 06:28:03 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E4=BF=9D=E8=AD=B7=20endpo?= =?UTF-8?q?int?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tw165.yml | 4 +++- AutoBuild/tw_165.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) 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