action.yml
· 896 B · YAML
Raw
refresh:
needs: deploy # 仅在 deploy 成功后执行
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: szenius/set-timezone@v1.0 # 设置执行环境的时区
with:
timezoneLinux: "Asia/Shanghai"
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run refresh script
env:
# DOGECLOUD_ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
# DOGECLOUD_SECRET_KEY: ${{ secrets.SECRET_KEY }}
TENCENTCLOUD_SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }}
TENCENTCLOUD_SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY }}
run: |
# pip install requests
# python .github/scripts/refresh-dogecloud.py
pip install tencentcloud-sdk-python
python .github/scripts/refresh-eo.py
1 | |
2 | refresh: |
3 | needs: deploy # 仅在 deploy 成功后执行 |
4 | runs-on: ubuntu-latest |
5 | steps: |
6 | - uses: actions/checkout@v4 |
7 | - uses: szenius/set-timezone@v1.0 # 设置执行环境的时区 |
8 | with: |
9 | timezoneLinux: "Asia/Shanghai" |
10 | - name: Set up Python 3.12 |
11 | uses: actions/setup-python@v5 |
12 | with: |
13 | python-version: "3.12" |
14 | - name: Run refresh script |
15 | env: |
16 | # DOGECLOUD_ACCESS_KEY: ${{ secrets.ACCESS_KEY }} |
17 | # DOGECLOUD_SECRET_KEY: ${{ secrets.SECRET_KEY }} |
18 | TENCENTCLOUD_SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }} |
19 | TENCENTCLOUD_SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY }} |
20 | run: | |
21 | # pip install requests |
22 | # python .github/scripts/refresh-dogecloud.py |
23 | pip install tencentcloud-sdk-python |
24 | python .github/scripts/refresh-eo.py |
25 | |
26 |
refresh-eo.py
· 784 B · Python
Raw
import os
import json
from tencentcloud.common import credential
from tencentcloud.teo.v20220901 import teo_client, models
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
try:
cred = credential.Credential(
os.getenv("TENCENTCLOUD_SECRET_ID"),
os.getenv("TENCENTCLOUD_SECRET_KEY")
)
client = teo_client.TeoClient(cred, "")
req = models.CreatePurgeTaskRequest()
req.from_json_string(json.dumps({
"ZoneId": "zone-*************",
"Type": "purge_prefix",
"Targets": [
"https://blog.liushen.fun/"
]
}))
resp = client.CreatePurgeTask(req)
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print("刷新失败:", err)
1 | import os |
2 | import json |
3 | from tencentcloud.common import credential |
4 | from tencentcloud.teo.v20220901 import teo_client, models |
5 | from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException |
6 | |
7 | try: |
8 | cred = credential.Credential( |
9 | os.getenv("TENCENTCLOUD_SECRET_ID"), |
10 | os.getenv("TENCENTCLOUD_SECRET_KEY") |
11 | ) |
12 | client = teo_client.TeoClient(cred, "") |
13 | |
14 | req = models.CreatePurgeTaskRequest() |
15 | req.from_json_string(json.dumps({ |
16 | "ZoneId": "zone-*************", |
17 | "Type": "purge_prefix", |
18 | "Targets": [ |
19 | "https://blog.liushen.fun/" |
20 | ] |
21 | })) |
22 | |
23 | resp = client.CreatePurgeTask(req) |
24 | print(resp.to_json_string(indent=2)) |
25 | |
26 | except TencentCloudSDKException as err: |
27 | print("刷新失败:", err) |
28 |