Repository navigation
feat: 统一博客图片托管到阿里云 OSS + CDN #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,142 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| name: CDN SSL Certificate Management | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||
| # 每月 1 号和 15 号凌晨 4 点执行(错开博客 SSL 续期时间) | ||||||||||||||||||||||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||||||||||||||||||||||
| - cron: "0 20 1,15 * *" # UTC 20:00 = 北京时间 04:00 | ||||||||||||||||||||||||||||||||||||||||||||||
| # 支持手动触发 | ||||||||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||||||||||||||||||||
| force_renew: | ||||||||||||||||||||||||||||||||||||||||||||||
| description: "强制重新申请证书" | ||||||||||||||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||||||||||||||||||||||||||
| default: false | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||
| DOMAIN: "cdn.xkcoding.com" | ||||||||||||||||||||||||||||||||||||||||||||||
| EMAIL: "237497819@qq.com" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||
| cdn-ssl-manage: | ||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install acme.sh | ||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||
| curl https://get.acme.sh | sh -s email=${{ env.EMAIL }} | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "$HOME/.acme.sh" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - name: Configure Aliyun DNS API | ||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||
| export Ali_Key="${{ secrets.ALI_ACCESS_KEY_ID }}" | ||||||||||||||||||||||||||||||||||||||||||||||
| export Ali_Secret="${{ secrets.ALI_ACCESS_KEY_SECRET }}" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 保存到 acme.sh 账户配置 | ||||||||||||||||||||||||||||||||||||||||||||||
| ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 写入环境变量供后续步骤使用 | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Ali_Key=${{ secrets.ALI_ACCESS_KEY_ID }}" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Ali_Secret=${{ secrets.ALI_ACCESS_KEY_SECRET }}" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - name: Issue/Renew Certificate | ||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||
| FORCE_RENEW="${{ github.event.inputs.force_renew }}" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 检查是否需要强制续期 | ||||||||||||||||||||||||||||||||||||||||||||||
| FORCE_FLAG="" | ||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$FORCE_RENEW" = "true" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "🔄 强制重新申请证书..." | ||||||||||||||||||||||||||||||||||||||||||||||
| FORCE_FLAG="--force" | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 使用 DNS-01 验证申请/续期证书 | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "🔐 申请证书: ${{ env.DOMAIN }}" | ||||||||||||||||||||||||||||||||||||||||||||||
| ~/.acme.sh/acme.sh --issue \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --dns dns_ali \ | ||||||||||||||||||||||||||||||||||||||||||||||
| -d ${{ env.DOMAIN }} \ | ||||||||||||||||||||||||||||||||||||||||||||||
| $FORCE_FLAG \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --debug || { | ||||||||||||||||||||||||||||||||||||||||||||||
| # 如果证书已存在且未到期,--issue 会失败,这是正常的 | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "ℹ️ 证书可能已存在且未到期" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+62
|
||||||||||||||||||||||||||||||||||||||||||||||
| ~/.acme.sh/acme.sh --issue \ | |
| --dns dns_ali \ | |
| -d ${{ env.DOMAIN }} \ | |
| $FORCE_FLAG \ | |
| --debug || { | |
| # 如果证书已存在且未到期,--issue 会失败,这是正常的 | |
| echo "ℹ️ 证书可能已存在且未到期" | |
| } | |
| if ! ~/.acme.sh/acme.sh --issue \ | |
| --dns dns_ali \ | |
| -d ${{ env.DOMAIN }} \ | |
| $FORCE_FLAG \ | |
| --debug; then | |
| ACME_EXIT_CODE=$? | |
| # acme.sh 约定:退出码 2 通常表示证书已存在且未到期,无需续期 | |
| if [ "$ACME_EXIT_CODE" -eq 2 ]; then | |
| echo "ℹ️ 证书已存在且未到期,无需续期" | |
| else | |
| echo "❌ 证书申请/续期失败,退出码: $ACME_EXIT_CODE" | |
| exit "$ACME_EXIT_CODE" | |
| fi | |
| fi |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The secret name uses ALI_ACCESS_KEY_ID and ALI_ACCESS_KEY_SECRET (lines 32-33, 76-77), but according to the proposal.md documentation, the expected secret names are ALI_KEY and ALI_SECRET. This inconsistency could cause the workflow to fail if secrets are configured using the documented names. Either update the workflow to use ALI_KEY and ALI_SECRET, or update all documentation to specify ALI_ACCESS_KEY_ID and ALI_ACCESS_KEY_SECRET.
| --access-key-id ${{ secrets.ALI_ACCESS_KEY_ID }} \ | |
| --access-key-secret ${{ secrets.ALI_ACCESS_KEY_SECRET }} | |
| --access-key-id ${{ secrets.ALI_KEY }} \ | |
| --access-key-secret ${{ secrets.ALI_SECRET }} |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verification step at line 126 tests HTTPS with a specific hardcoded image URL "2017-07-12-14998277900006.jpg". This creates a dependency on that specific image existing in the OSS bucket. If that image is missing or the path changes, the verification will fail even if the SSL certificate is correctly deployed. Consider using a more generic verification approach, such as checking the SSL certificate itself or testing the domain root URL.
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://${{ env.DOMAIN }}/2017-07-12-14998277900006.jpg" || echo "000") | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://${{ env.DOMAIN }}/" || echo "000") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new CDN domain is
cdn.xkcoding.comaccording to the PR title and description, but in the GitHub Actions workflow, the DOMAIN environment variable is set tocdn.xkcoding.comat line 17, while the design documentation and actual markdown replacements usestatic.xkcoding.com. This inconsistency needs to be resolved. Either update the workflow to usestatic.xkcoding.comor update all markdown files and documentation to usecdn.xkcoding.com.