From ad22a0f2255669157a91561cd6c6739bc1fa981f Mon Sep 17 00:00:00 2001 From: SukkaW Date: Wed, 4 Sep 2024 02:10:52 +0800 Subject: [PATCH] CI: deploy to Cloudflare Pages --- .github/workflows/main.yml | 6 ++++++ Build/download-previous-build.ts | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 471ca1a4..94bf1481 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,6 +64,12 @@ jobs: echo "public directory is empty" exit 1 fi + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy public --project-name=sukkaw-ruleset --commit-dirty=true --branch=main - name: Deploy uses: peaceiris/actions-gh-pages@v4 with: diff --git a/Build/download-previous-build.ts b/Build/download-previous-build.ts index d85aa3c1..7be91d1f 100644 --- a/Build/download-previous-build.ts +++ b/Build/download-previous-build.ts @@ -52,7 +52,19 @@ export const downloadPreviousBuild = task(require.main === module, __filename)(a return span .traceChild('download & extract previoud build') .traceAsyncFn(async () => { - const resp = await fetchWithRetry('https://codeload.github.com/sukkalab/ruleset.skk.moe/tar.gz/master', defaultRequestInit); + const resp = await fetchWithRetry('https://codeload.github.com/sukkalab/ruleset.skk.moe/tar.gz/master', { + ...defaultRequestInit, + retry: { + retryOnNon2xx: false + } + }); + + if (resp.status !== 200) { + console.warn('Download previous build failed! Status:', resp.status); + if (resp.status === 404) { + return; + } + } if (!resp.body) { throw new Error('Download previous build failed! No body found');