This commit is contained in:
小赵同学 committed 2024-09-16 13:37:30 +08:00
commit 3e6099bb7e
2 files changed
+20 -4

No files matched your search

+9 -1
View File
@@ -3,7 +3,7 @@ name: Refresh CDN
on:
push:
branches:
- master
- main
jobs:
refresh-cdn:
@@ -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 }}
+11 -3
View File
@@ -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',