cloudflare / pages-action

MIT License
440 stars 91 forks source link

Deploying with cloudflare/pages-action but cannot locate sveltekit build directory #110

Closed socketopp closed 6 months ago

socketopp commented 6 months ago

Which Cloudflare product(s) does this pertain to?

Pages, Wrangler core

What version(s) of the tool(s) are you using?

wrangler: 3.20.0

What version of Node are you using?

v18.17.0

What operating system are you using?

Windows

Describe the Bug

Following build error occurred when trying to deploy a Sveltekit page using adapter-cloudflare which says I should be using .svelte-kit/cloudflare as the build output directory.

I am not a build expert and would really like to learn what's wrong here. I have been following the instructions in the cloudflare/pages-action project.

Here is the build script: .github\workflows\publish.yml

on:
  push:
    branches:
      - develop
      - master
jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    name: Publish to Cloudflare Pages
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Print with LS
        run: ls -a
      - name: Build & Deploy Worker - Development
        if: github.ref == 'refs/heads/develop'
        uses: cloudflare/pages-action@v1
        with:
          projectName: my_project
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN  }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          directory: .svelte-kit/cloudflare
          branch: develop
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
      - name: Build & Deploy Worker - Production
        if: github.ref == 'refs/heads/master'
        uses: cloudflare/pages-action@v1
        with:
          projectName: my_project
          directory: .svelte-kit/cloudflare
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          branch: master
          wranglerVersion: '3'
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

The following command failed:

2023-12-23T14:01:41.7394803Z SHELLAC COMMAND FAILED!
2023-12-23T14:01:41.7396522Z Executing: npx wrangler@2 pages publish ".svelte-kit/cloudflare" --project-name="my_project" --branch="develop" in /home/runner/work/my_project/my_project

Here is a summary of the log:

Run cloudflare/pages-action@v1
  with:
    projectName: my_project
    apiToken: ***
    accountId: ***
    directory: .svelte-kit/cloudflare
    branch: develop
    gitHubToken: ***
    wranglerVersion: 2
npm WARN exec The following package was not found and will be installed: wrangler@2.20.2
npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead

✘ [ERROR] ENOENT: no such file or directory, scandir '/home/runner/work/my_project/my_project/.svelte-kit/cloudflare'
WalshyDev commented 6 months ago

It seems like you aren't building your SvelteKit project - you'll want to run your build command first (by default this seems like npm run build - https://kit.svelte.dev/docs/building-your-app) before you try and deploy.

ChronSyn commented 2 months ago

Are you sure about that? It seems to me that the issue is that the path is doubling-up on the my_project - i.e. the original issue says as the path /home/runner/work/my_project/my_project/

If you try to set workingDirectory to /home/runner/work/my_project/, it'll append that to the end, resulting in it trying to locate /home/runner/work/my_project/my_project/home/runner/work/my_project/.

Setting workingDirectory to .. appears to resolve this doubling.