Skip to content

Commit 06b1cd8

Browse files
committed
chore: Refresh Tencent Cloud CDN
1 parent 35e4c88 commit 06b1cd8

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

.github/workflows/pages.yml

+47-47
Original file line numberDiff line numberDiff line change
@@ -48,56 +48,56 @@ jobs:
4848
- name: Deploy to GitHub Pages
4949
id: deployment
5050
uses: actions/deploy-pages@v4
51-
# - name: Refresh Tencent Cloud CDN
52-
# env:
53-
# SECRET_ID: ${{ secrets.SECRETID }}
54-
# SECRET_KEY: ${{ secrets.SECRETKEY }}
55-
# DOMAIN_Path: 'https://www.ilikestudy.cn/*'
56-
# run: |
57-
# secret_id="${SECRET_ID}"
58-
# secret_key="${SECRET_KEY}"
59-
# token=""
51+
- name: Refresh Tencent Cloud CDN
52+
env:
53+
SECRET_ID: ${{ secrets.SECRETID }}
54+
SECRET_KEY: ${{ secrets.SECRETKEY }}
55+
DOMAIN_Path: 'https://www.ilikestudy.cn/*'
56+
run: |
57+
secret_id="${SECRET_ID}"
58+
secret_key="${SECRET_KEY}"
59+
token=""
6060
61-
# service="cdn"
62-
# host="cdn.tencentcloudapi.com"
63-
# region=""
64-
# action="PurgePathCache"
65-
# version="2018-06-06"
66-
# algorithm="TC3-HMAC-SHA256"
67-
# timestamp=$(date +%s)
68-
# date=$(date -u -d @$timestamp +"%Y-%m-%d")
69-
# payload="{\"Paths\":[\"${DOMAIN_Path}\"],\"FlushType\":\"delete\"}"
61+
service="cdn"
62+
host="cdn.tencentcloudapi.com"
63+
region=""
64+
action="PurgePathCache"
65+
version="2018-06-06"
66+
algorithm="TC3-HMAC-SHA256"
67+
timestamp=$(date +%s)
68+
date=$(date -u -d @$timestamp +"%Y-%m-%d")
69+
payload="{\"Paths\":[\"${DOMAIN_Path}\"],\"FlushType\":\"delete\"}"
7070
71-
# # 生成规范请求串
72-
# http_request_method="POST"
73-
# canonical_uri="/"
74-
# canonical_querystring=""
75-
# canonical_headers="content-type:application/json; charset=utf-8\nhost:$host\nx-tc-action:$(echo $action | awk '{print tolower($0)}')\n"
76-
# signed_headers="content-type;host;x-tc-action"
77-
# hashed_request_payload=$(echo -n "$payload" | openssl sha256 -hex | awk '{print $2}')
78-
# canonical_request="$http_request_method\n$canonical_uri\n$canonical_querystring\n$canonical_headers\n$signed_headers\n$hashed_request_payload"
71+
# 生成规范请求串
72+
http_request_method="POST"
73+
canonical_uri="/"
74+
canonical_querystring=""
75+
canonical_headers="content-type:application/json; charset=utf-8\nhost:$host\nx-tc-action:$(echo $action | awk '{print tolower($0)}')\n"
76+
signed_headers="content-type;host;x-tc-action"
77+
hashed_request_payload=$(echo -n "$payload" | openssl sha256 -hex | awk '{print $2}')
78+
canonical_request="$http_request_method\n$canonical_uri\n$canonical_querystring\n$canonical_headers\n$signed_headers\n$hashed_request_payload"
7979
80-
# # 构造待签名字符串
81-
# credential_scope="$date/$service/tc3_request"
82-
# hashed_canonical_request=$(printf "$canonical_request" | openssl sha256 -hex | awk '{print $2}')
83-
# string_to_sign="$algorithm\n$timestamp\n$credential_scope\n$hashed_canonical_request"
80+
# 构造待签名字符串
81+
credential_scope="$date/$service/tc3_request"
82+
hashed_canonical_request=$(printf "$canonical_request" | openssl sha256 -hex | awk '{print $2}')
83+
string_to_sign="$algorithm\n$timestamp\n$credential_scope\n$hashed_canonical_request"
8484
85-
# # 计算签名
86-
# secret_date=$(printf "$date" | openssl sha256 -hmac "TC3$secret_key" | awk '{print $2}')
87-
# secret_service=$(printf $service | openssl dgst -sha256 -mac hmac -macopt hexkey:"$secret_date" | awk '{print $2}')
88-
# secret_signing=$(printf "tc3_request" | openssl dgst -sha256 -mac hmac -macopt hexkey:"$secret_service" | awk '{print $2}')
89-
# signature=$(printf "$string_to_sign" | openssl dgst -sha256 -mac hmac -macopt hexkey:"$secret_signing" | awk '{print $2}')
85+
# 计算签名
86+
secret_date=$(printf "$date" | openssl sha256 -hmac "TC3$secret_key" | awk '{print $2}')
87+
secret_service=$(printf $service | openssl dgst -sha256 -mac hmac -macopt hexkey:"$secret_date" | awk '{print $2}')
88+
secret_signing=$(printf "tc3_request" | openssl dgst -sha256 -mac hmac -macopt hexkey:"$secret_service" | awk '{print $2}')
89+
signature=$(printf "$string_to_sign" | openssl dgst -sha256 -mac hmac -macopt hexkey:"$secret_signing" | awk '{print $2}')
9090
91-
# # 构造 Authorization 头部
92-
# authorization="$algorithm Credential=$secret_id/$credential_scope, SignedHeaders=$signed_headers, Signature=$signature"
91+
# 构造 Authorization 头部
92+
authorization="$algorithm Credential=$secret_id/$credential_scope, SignedHeaders=$signed_headers, Signature=$signature"
9393
94-
# # 发起请求
95-
# curl -XPOST "https://$host" -d "$payload" \
96-
# -H "Authorization: $authorization" \
97-
# -H "Content-Type: application/json; charset=utf-8" \
98-
# -H "Host: $host" \
99-
# -H "X-TC-Action: $action" \
100-
# -H "X-TC-Timestamp: $timestamp" \
101-
# -H "X-TC-Version: $version" \
102-
# -H "X-TC-Region: $region" \
103-
# -H "X-TC-Token: $token"
94+
# 发起请求
95+
curl -XPOST "https://$host" -d "$payload" \
96+
-H "Authorization: $authorization" \
97+
-H "Content-Type: application/json; charset=utf-8" \
98+
-H "Host: $host" \
99+
-H "X-TC-Action: $action" \
100+
-H "X-TC-Timestamp: $timestamp" \
101+
-H "X-TC-Version: $version" \
102+
-H "X-TC-Region: $region" \
103+
-H "X-TC-Token: $token"

0 commit comments

Comments
 (0)