From 93089b105a39060e94b631ac71230f1dd303b8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B5=B5=E5=90=8C=E5=AD=A6?= <94612053+imzql@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:25:45 +0800 Subject: [PATCH 1/3] Update RefreshCDN.yml --- .github/workflows/RefreshCDN.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/RefreshCDN.yml b/.github/workflows/RefreshCDN.yml index 287f27c6..1169d545 100644 --- a/.github/workflows/RefreshCDN.yml +++ b/.github/workflows/RefreshCDN.yml @@ -3,7 +3,7 @@ name: Refresh CDN on: push: branches: - - master + - main jobs: refresh-cdn: From cc43b46f9907a6b2abef03023c0ac09c65277754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B5=B5=E5=90=8C=E5=AD=A6?= <94612053+imzql@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:20:30 +0800 Subject: [PATCH 2/3] Update RefreshCDN.py --- RefreshCDN.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/RefreshCDN.py b/RefreshCDN.py index 46af100c..8c035275 100644 --- a/RefreshCDN.py +++ b/RefreshCDN.py @@ -15,8 +15,11 @@ def dogecloud_api(api_path, data={}, json_mode=False): :return dict: 返回的数据。 """ - access_key = '4fa23701981899fb' # 替换为自己的 AccessKey - secret_key = 'feea91f5781378c4e7f16da1632fc7fd' # 替换为自己的 SecretKey + access_key = os.environ.get('DOGECLOUD_ACCESS_KEY') # 从环境变量获取 AccessKey + secret_key = os.environ.get('DOGECLOUD_SECRET_KEY') # 从环境变量获取 SecretKey + + if not access_key or not secret_key: + raise ValueError("Access Key or Secret Key is not set in environment variables.") body = '' mime = '' @@ -38,7 +41,12 @@ def dogecloud_api(api_path, data={}, json_mode=False): }) return response.json() -url_list = ['https://usj.cc/'] # 替换为你的博客域名 +# 从环境变量中获取 URL 列表,使用逗号分隔 +url_list_env = os.environ.get('CDN_URL_LIST') +if not url_list_env: + raise ValueError("CDN_URL_LIST is not set in environment variables.") + +url_list = url_list_env.split(',') api = dogecloud_api('/cdn/refresh/add.json', { 'rtype': 'path', From 95fd742d5f1aace45dbc99e147ae27a98b7040ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B5=B5=E5=90=8C=E5=AD=A6?= <94612053+imzql@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:21:16 +0800 Subject: [PATCH 3/3] Update RefreshCDN.yml --- .github/workflows/RefreshCDN.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/RefreshCDN.yml b/.github/workflows/RefreshCDN.yml index 1169d545..3dab74c4 100644 --- a/.github/workflows/RefreshCDN.yml +++ b/.github/workflows/RefreshCDN.yml @@ -11,13 +11,21 @@ jobs: steps: - name: 检出代码 uses: actions/checkout@v2 + - name: 安装 Python uses: actions/setup-python@v2 with: python-version: '3.x' + - name: 安装依赖 run: pip install requests + - name: 等待源站部署 run: sleep 1m # 这里用了个笨办法,等待 1 分钟后进行刷新 + - name: 刷新 CDN run: python RefreshCDN.py + env: + DOGECLOUD_ACCESS_KEY: ${{ secrets.DOGECLOUD_ACCESS_KEY }} + DOGECLOUD_SECRET_KEY: ${{ secrets.DOGECLOUD_SECRET_KEY }} + CDN_URL_LIST: ${{ secrets.CDN_URL_LIST }}