 LiuShen revisó este gist 3 months ago. Ir a la revisión
                
                LiuShen revisó este gist 3 months ago. Ir a la revisión
                
                    2 files changed, 52 insertions
action.yml(archivo creado)
| @@ -0,0 +1,25 @@ | |||
| 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 | + | ||
refresh-eo.py(archivo creado)
| @@ -0,0 +1,27 @@ | |||
| 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) | |
    
    
                            
                            Siguiente
    
    
    Anterior