8000 Support Deno by jp-knj · Pull Request #77 · withastro/action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support Deno #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
< 8000 input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput">
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
strategy:
matrix:
pm: [deno, pnpm]
45 changes: 36 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ inputs:
description: "Path of the directory containing your site"
required: false
default: "."
deno-version:
description: "The Deno version to use when deno.json/deno.jsonc/deno.lock exists"
required: false
default: "1.x"
deno-setup-task:
description: "Name of the optional Deno task to run before build (will be skipped if undefined)"
required: false
default: "setup"

runs:
using: composite
Expand Down Expand Up @@ -53,6 +61,10 @@ runs:
VERSION="latest"
echo "PACKAGE_MANAGER=bun" >> $GITHUB_ENV
echo "LOCKFILE=bun.lockb" >> $GITHUB_ENV
elif [ -f "deno.json" ] || [ -f "deno.jsonc" ] || [ -f "deno.lock" ]; then
VERSION="${{ inputs.deno-version }}"
echo "PACKAGE_MANAGER=deno" >> $GITHUB_ENV
echo "LOCKFILE=deno.lock" >> $GITHUB_ENV
else
echo "No lockfile found.
Please specify your preferred \"package-manager\" in the action configuration."
Expand All @@ -72,9 +84,15 @@ runs:
with:
bun-version: ${{ env.VERSION }}

- name: Setup Deno
if: ${{ env.PACKAGE_MANAGER == 'deno' }}
uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.VERSION }}

- name: Setup Node
uses: actions/setup-node@v4
if: ${{ env.PACKAGE_MANAGER != 'bun' }}
if: ${{ env.PACKAGE_MANAGER != 'bun' && env.PACKAGE_MANAGER != 'deno' }}
with:
node-version: ${{ inputs.node-version }}
cache: ${{ env.PACKAGE_MANAGER }}
Expand All @@ -86,17 +104,26 @@ runs:
with:
node-version: ${{ inputs.node-version }}

- name: Install
shell: "bash"
- name: Install (npm/yarn/pnpm)
if: ${{ env.PACKAGE_MANAGER != 'deno' }}
shell: bash
working-directory: ${{ inputs.path }}
run: $PACKAGE_MANAGER install

- name: Build
shell: "bash"
- name: Cache deps & vendor (Deno)
if: ${{ env.PACKAGE_MANAGER == 'deno' }}
shell: bash
working-directory: ${{ inputs.path }}
run: deno task ${{ inputs.deno-setup-task }} || echo "No deno ${{ inputs.deno-setup-task }} task defined - skipping"

- name: Build (npm/yarn/pnpm/bun)
if: ${{ env.PACKAGE_MANAGER != 'deno' }}
shell: bash
working-directory: ${{ inputs.path }}
run: $PACKAGE_MANAGER run build

- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
with:
path: "${{ inputs.path }}/dist/"
- name: Build (Deno)
if: ${{ env.PACKAGE_MANAGER == 'deno' }}
shell: bash
working-directory: ${{ inputs.path }}
run: deno task build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this one is user-defined just like the build script for npm/pnpm/yarn/bun run build. Would Deno use the script from package.json that create-astro generates or do users need to define the same astro build on something from Deno?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Fryuni,

  • build is required; it’s the Deno-side equivalent of npm run build.
  • For Astro we usually point it at the CLI via Deno’s npm compatibility layer:
{
  "tasks": {
    "build": "npm:astro build"
  }
}
  • When you scaffold a new site with create-astro --deno (incoming PR), those two tasks will be added automatically, so users won’t have to think about them.

Why not reuse the package.json script?

A pure-Deno project typically has no package.json at all, so deferring to deno task keeps everything in one place and lets us skip Node setup entirely. Deno resolves the npm: specifier internally, so we still get the real Astro CLI without needing npm install.

0