diff --git a/.github/workflows/build-and-deploy.yaml b/.github/workflows/publish-and-deploy.yaml similarity index 75% rename from .github/workflows/build-and-deploy.yaml rename to .github/workflows/publish-and-deploy.yaml index 02e8f47..d209767 100644 --- a/.github/workflows/build-and-deploy.yaml +++ b/.github/workflows/publish-and-deploy.yaml @@ -1,4 +1,4 @@ -name: Deploy to Cloudflare Pages +name: Publish and Deploy on: push: @@ -7,7 +7,7 @@ on: workflow_dispatch: jobs: - build: + publish: runs-on: ubuntu-latest steps: - name: Checkout repository @@ -31,16 +31,16 @@ jobs: restore-keys: | ${{ runner.os }}-deno-cache- - - name: Build Project - run: deno task build + - name: Publish Project + run: deno task publish - name: Upload build artifacts uses: actions/upload-artifact@v4 with: - name: static-files - path: static/ + name: dist-files + path: dist/ deploy: - needs: build + needs: publish runs-on: ubuntu-latest permissions: contents: read @@ -49,15 +49,15 @@ jobs: - name: Download build artifacts uses: actions/download-artifact@v4 with: - name: static-files - path: static/ + name: dist-files + path: dist/ - - name: "List static directory contents" - run: ls -R static + - name: "List publish directory contents" + run: ls -R dist - name: Deploy to Cloudflare pages uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy static --project-name=armorynodewebsite + command: pages deploy dist --project-name=armorynodewebsite diff --git a/.gitignore b/.gitignore index 7eeaf65..63ed085 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,6 @@ static/css/*.min.css # Node modules node_modules/ # Wrangler -.wrangler/ \ No newline at end of file +.wrangler/ +# published artifacts +dist/ \ No newline at end of file diff --git a/build.ts b/build.ts index be3dc98..13e2929 100644 --- a/build.ts +++ b/build.ts @@ -44,6 +44,7 @@ async function compileSass() { // Only run if the script is run directly, not imported as a module if (import.meta.main) { await compile(); + console.log("✅ Done!"); } export async function compile() { @@ -54,6 +55,4 @@ export async function compile() { console.log("🌳 Compiling Elm..."); await compileAndMinifyElm(); - - console.log("✅ Done!"); } diff --git a/deno.json b/deno.json index c6923ac..234b81c 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,7 @@ { "tasks": { "build": "deno run --allow-read --allow-env --allow-write --allow-run build.ts", + "publish": "deno run --allow-read --allow-env --allow-write --allow-run publish.ts", "run": "deno run --allow-read --allow-env --allow-write --allow-run run.ts" } } \ No newline at end of file diff --git a/deno.lock b/deno.lock index 6a3222b..05af9fb 100644 --- a/deno.lock +++ b/deno.lock @@ -1,9 +1,22 @@ { "version": "4", "specifiers": { + "jsr:@std/fs@*": "1.0.9", + "jsr:@std/path@^1.0.8": "1.0.8", "npm:sass@*": "1.83.4", "npm:terser@*": "5.37.0" }, + "jsr": { + "@std/fs@1.0.9": { + "integrity": "3eef7e3ed3d317b29432c7dcb3b20122820dbc574263f721cb0248ad91bad890", + "dependencies": [ + "jsr:@std/path" + ] + }, + "@std/path@1.0.8": { + "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" + } + }, "npm": { "@jridgewell/gen-mapping@0.3.8": { "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", diff --git a/publish.ts b/publish.ts new file mode 100644 index 0000000..f1a121d --- /dev/null +++ b/publish.ts @@ -0,0 +1,18 @@ +import * as fs from "jsr:@std/fs"; +import { compile } from "./build.ts"; + +/// Builds and publishes necessary files to `dist/` for deployment. +async function publish() { + console.log("🏗️ Running build step..."); + await compile(); + + console.log("🚀 Publishing files to `dist/`..."); + await Deno.mkdir("./dist", { recursive: true }); + await fs.copy("./static", "./dist/static", { overwrite: true }); + await fs.copy("./functions", "./dist/functions", { overwrite: true }); + await fs.copy("./wrangler.toml", "./dist/wrangler.toml", { overwrite: true }); + + console.log("✅ Publish complete!"); +} + +await publish(); \ No newline at end of file