diff --git a/.github/tools/github_actions_deno_deploy.ts b/.github/tools/github_actions_deno_deploy.ts index 105a824..0a89bce 100644 --- a/.github/tools/github_actions_deno_deploy.ts +++ b/.github/tools/github_actions_deno_deploy.ts @@ -1,20 +1,9 @@ +// deno-lint-ignore-file no-explicit-any // Imports import * as JSONC from "@std/jsonc" import * as core from "@actions/core" -// Ensure script is run in CI environment -if (!Deno.env.get("CI")) { - throw new Error("This script should be run only in CI environment") -} - -// Remove lockfiles and package.json to avoid resolution conflicts -// https://github.com/denoland/deno/issues/27380 -await Deno.remove("deno.lock", { recursive: true }) -await Deno.remove("package.json", { recursive: true }) -await Deno.remove("package-lock.json", { recursive: true }) - // Parse deno.jsonc and print deno deploy flags -// deno-lint-ignore no-explicit-any const config = JSONC.parse(await Deno.readTextFile("./deno.jsonc")) as any await Deno.writeTextFile(".imports.json", JSON.stringify({ imports: config.imports }, null, 2)) core.setOutput("project", config.deploy.project) diff --git a/deno.jsonc b/deno.jsonc index fdb06f6..9d3dd25 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -51,6 +51,10 @@ "command": "cd $INIT_CWD && bun test" }, // Building tasks + "build:lockfile": { + "description": "Build deno.lock and package-lock.json", + "command": "rm -rf deno.lock package.json package-lock.json && deno install && git checkout package.json && npm install" + }, "build:www": { "description": "Build website", "command": "deno run --quiet --allow-read --allow-env --allow-net --allow-sys=osRelease --allow-write=www/.pages --allow-run=$(deno task resolve:glob \"$DENO_DIR/**/@esbuild/**/esbuild\") --location=http://localhost:4649 www/build.ts", @@ -68,13 +72,13 @@ // Continuous integration tasks "ci:setup-deno-deploy": { "description": "Setup deno deploy environment", - "command": "deno run --allow-read --allow-env --allow-write=.imports.json,deno.lock,package.json,package-lock.json,/home/runner/work/_temp .github/tools/github_actions_deno_deploy.ts", + "command": "deno task build:lockfile && rm -rf package.json package-lock.json && deno run --allow-read --allow-env --allow-write=.imports.json,/home/runner/work/_temp .github/tools/github_actions_deno_deploy.ts", "dependencies": ["build:www", "build:coverage", "render:mermaid"] }, "ci:autogenerate": { "description": "Autogenerate files", "command": "sleep 0", - "dependencies": ["repo:fill-scopes", "render:mermaid", "render:readmes"] + "dependencies": ["build:lockfile", "repo:fill-scopes", "render:mermaid", "render:readmes"] }, // Development tasks "qa": {