-
Notifications
You must be signed in to change notification settings - Fork 336
38 lines (30 loc) · 1.35 KB
/
dockerhub_proxy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Build and push to CloudFlare Worker
on:
workflow_dispatch:
jobs:
build:
name: Spellcheck
runs-on: ubuntu-latest
steps:
# The checkout step
- name: Checkout
uses: actions/checkout@v4
- name: Download Markdown file and update cloudflare.js
run: |
cd docker
curl -o dockerhub-proxy.md https://raw.githubusercontent.com/Websoft9/doc.websoft9.com/refs/heads/main/docs/reference/_include/dockerhub-proxy.md
# 提取 Markdown 文件中的 URL
urls=$(grep -Eo 'https://[a-zA-Z0-9./?=_-]*' dockerhub-proxy.md | sed 's/^/"/; s/$/"/' | tr '\n' ',' | sed 's/,$//')
# 创建新的 backends 数组
new_backends="const backends = [${urls}]"
# 更新 cloudflare.js 文件中的 backends 数组
sed -i "s|var backends = \[.*\]|${new_backends}|" cloudflare.js
- name: Set compatibility date
id: set-date
run: echo "COMPATIBILITY_DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV
- name: Deploy to cloudflare
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.EDIT_CLOUDFLARE_WORKERS }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy docker/cloudflare.js --name dockerhub --compatibility-date ${{ env.COMPATIBILITY_DATE }}