From fa2f5d4c6cbb4e28aa9d2c468675044bef86c623 Mon Sep 17 00:00:00 2001 From: jp-knj Date: Sat, 3 May 2025 22:05:03 +0900 Subject: [PATCH 1/2] feat: add deno support --- .github/workflows/ci.yml | 3 +++ action.yml | 41 +++++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..47076af --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,3 @@ +strategy: + matrix: + pm: [deno, pnpm] diff --git a/action.yml b/action.yml index 8659127..e464348 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,10 @@ 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" runs: using: composite @@ -53,6 +57,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." @@ -72,9 +80,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 }} @@ -86,17 +100,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 _prepare + + - 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 From ecde5fe17a6d2dfa6d9a474d042a8d81d55d1076 Mon Sep 17 00:00:00 2001 From: jp-knj Date: Mon, 19 May 2025 00:16:47 +0900 Subject: [PATCH 2/2] feat: make it configurable --- action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e464348..6218f88 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,10 @@ inputs: 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 @@ -110,7 +114,7 @@ runs: if: ${{ env.PACKAGE_MANAGER == 'deno' }} shell: bash working-directory: ${{ inputs.path }} - run: deno task _prepare + 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' }}