Merge branch 'main' of https://github.com/imzql/blog
This commit is contained in:
commit
196d6df728
2 files changed
+20
-4
No files matched your search
@@ -3,7 +3,7 @@ name: Refresh CDN
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
refresh-cdn:
|
refresh-cdn:
|
||||||
@@ -11,13 +11,21 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: 安装 Python
|
- name: 安装 Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: 安装依赖
|
- name: 安装依赖
|
||||||
run: pip install requests
|
run: pip install requests
|
||||||
|
|
||||||
- name: 等待源站部署
|
- name: 等待源站部署
|
||||||
run: sleep 1m # 这里用了个笨办法,等待 1 分钟后进行刷新
|
run: sleep 1m # 这里用了个笨办法,等待 1 分钟后进行刷新
|
||||||
|
|
||||||
- name: 刷新 CDN
|
- name: 刷新 CDN
|
||||||
run: python RefreshCDN.py
|
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
@@ -15,8 +15,11 @@ def dogecloud_api(api_path, data={}, json_mode=False):
|
|||||||
|
|
||||||
:return dict: 返回的数据。
|
:return dict: 返回的数据。
|
||||||
"""
|
"""
|
||||||
access_key = '4fa23701981899fb' # 替换为自己的 AccessKey
|
access_key = os.environ.get('DOGECLOUD_ACCESS_KEY') # 从环境变量获取 AccessKey
|
||||||
secret_key = 'feea91f5781378c4e7f16da1632fc7fd' # 替换为自己的 SecretKey
|
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 = ''
|
body = ''
|
||||||
mime = ''
|
mime = ''
|
||||||
@@ -38,7 +41,12 @@ def dogecloud_api(api_path, data={}, json_mode=False):
|
|||||||
})
|
})
|
||||||
return response.json()
|
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', {
|
api = dogecloud_api('/cdn/refresh/add.json', {
|
||||||
'rtype': 'path',
|
'rtype': 'path',
|
||||||
|
|||||||
Reference in new issue
Block a user