From 1d779db4d72cac1211dad7a620ee906c92c08b4c Mon Sep 17 00:00:00 2001 From: shxyke Date: Tue, 25 Jun 2024 10:21:05 +0800 Subject: [PATCH] chore: Update deployment configuration for custom domain --- .github/workflows/deploy.yaml | 4 ++++ .github/workflows/stage.yaml | 4 ++++ src/index.js | 18 +++++++++--------- wrangler.toml | 3 +++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 84733705..21f7d81a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -16,8 +16,12 @@ jobs: - uses: actions/checkout@v4 - name: Publish uses: cloudflare/wrangler-action@v3 + env: + CUSTOM_DOMAIN: ${{ secrets.CUSTOM_DOMAIN || 'libcuda.so' }} with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{secrets.CF_ACCOUNT_ID}} + vars: + CUSTOM_DOMAIN command: deploy --env production --minify src/index.js environment: production \ No newline at end of file diff --git a/.github/workflows/stage.yaml b/.github/workflows/stage.yaml index db045f69..1b3f82d4 100644 --- a/.github/workflows/stage.yaml +++ b/.github/workflows/stage.yaml @@ -16,8 +16,12 @@ jobs: - uses: actions/checkout@v4 - name: Publish uses: cloudflare/wrangler-action@v3 + env: + CUSTOM_DOMAIN: ${{ secrets.CUSTOM_DOMAIN || 'libcuda.so' }} with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{secrets.CF_ACCOUNT_ID}} + vars: + CUSTOM_DOMAIN command: deploy --env staging --minify src/index.js environment: staging \ No newline at end of file diff --git a/src/index.js b/src/index.js index 97b08852..e551bec9 100644 --- a/src/index.js +++ b/src/index.js @@ -7,17 +7,17 @@ const dockerHub = "https://registry-1.docker.io"; const routes = { // production - "docker.libcuda.so": dockerHub, - "quay.libcuda.so": "https://quay.io", - "gcr.libcuda.so": "https://gcr.io", - "k8s-gcr.libcuda.so": "https://k8s.gcr.io", - "k8s.libcuda.so": "https://registry.k8s.io", - "ghcr.libcuda.so": "https://ghcr.io", - "cloudsmith.libcuda.so": "https://docker.cloudsmith.io", - "ecr.libcuda.so": "https://public.ecr.aws", + ["docker." + CUSTOM_DOMAIN]: dockerHub, + ["quay." + CUSTOM_DOMAIN]: "https://quay.io", + ["gcr." + CUSTOM_DOMAIN]: "https://gcr.io", + ["k8s-gcr." + CUSTOM_DOMAIN]: "https://k8s.gcr.io", + ["k8s." + CUSTOM_DOMAIN]: "https://registry.k8s.io", + ["ghcr." + CUSTOM_DOMAIN]: "https://ghcr.io", + ["cloudsmith." + CUSTOM_DOMAIN]: "https://docker.cloudsmith.io", + ["ecr." + CUSTOM_DOMAIN]: "https://public.ecr.aws", // staging - "docker-staging.libcuda.so": dockerHub, + ["docker-staging." + CUSTOM_DOMAIN]: dockerHub, }; function routeByHosts(host) { diff --git a/wrangler.toml b/wrangler.toml index c3077a0f..b245b957 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -6,6 +6,9 @@ ip = "0.0.0.0" port = 8787 local_protocol = "http" +[env.vars] +CUSTOM_DOMAIN = "libcuda.so" + [env.dev.vars] MODE = "debug" TARGET_UPSTREAM = "https://registry-1.docker.io"