denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[Bug]: Deno deploy is not working as it's said #671

Closed rajrupdasofficial closed 5 months ago

rajrupdasofficial commented 5 months ago

Problem description

when i am trying to deploy my fresh framework website from deno deploy (web not cli) it's keep saying that 500 internal server error i have tried with many different options nothing working?

is this your easy to deploy platform?

here is the error and it's response

{"projectId":"6f4be189-f771-4cd8-bb2b-592c540830da","path":".github/workflows/deploy.yml","content":"name: Deploy\non:\n push:\n branches: master\n pull_request:\n branches: master\n\njobs:\n deploy:\n name: Deploy\n runs-on: ubuntu-latest\n\n permissions:\n id-token: write # Needed for auth with Deno Deploy\n contents: read # Needed to clone the repository\n\n steps:\n - name: Clone repository\n uses: actions/checkout@v4\n\n - name: Install Deno\n uses: denoland/setup-deno@v1\n with:\n deno-version: v1.x\n\n - name: Build step\n run: \"deno task build\"\n\n - name: Upload to Deno Deploy\n uses: denoland/deployctl@v1\n with:\n project: \"webstackpro-wwwdsds\"\n entrypoint: \"main.ts\"\n root: \"_fresh\"\n"}

{"name":"ApiError","status":500,"code":"internalServerError","traceId":"f089fdf4e2876bf4258949dd00b78b42","retryAfterSec":null,"message":"An internal server error occurred."}

Steps to reproduce

setup a simple fresh project

try do deploy from github

it will fail

and give error codes as i mentioned previously

Expected behavior

it should deploy the project without any hassel as it's bragging about in the landing page.

"Hassle-free platform for serverless JavaScript applications"

Environment

Deno version - latest (v 1.44)

fresh framework (1.6.8)

Possible solution

Don't know ,

but i must say documentation is absolutely unclear

and the platform is not good as it's saying.

Additional context

No response

willnewby commented 5 months ago

Hey @RajrupDasid, can you point me to your Github Actions yaml and your Fresh code (if it's open, post a link here, if it's private, feel free to email me at will at deno dot com)?

i have tried with many different options nothing working?

Can you let us know what options you tried?

I'm happy to help figure out your issue, I'm just not clear on your setup.

willnewby commented 5 months ago

Quick followup: Looking at our error logs, I'm seeing

Could not create file: Changes must be made through a pull request.

Do you have branch protection turned on for your default branch?

rajrupdasofficial commented 5 months ago

Quick followup: Looking at our error logs, I'm seeing

Could not create file: Changes must be made through a pull request.

Do you have branch protection turned on for your default branch?

Yes i have branch protection enabled

rajrupdasofficial commented 5 months ago

https://github.com/RajrupDasid/webstackpros here is the repo link , and extremely sorry for late reply

rajrupdasofficial commented 5 months ago

please fix the issue ASAP

rajrupdasofficial commented 5 months ago

let me know if you need any other information, and yes about the configuration i select - fresh build and deploy option.

It's little bit confusing on deno than vercel. For this issue I had to rewrite my company website in sveltekit, to deploy it properly.

magurotuna commented 5 months ago

Thanks for additional info.

Here are several options to get around the issue:

  1. Temporarily disable the branch protection while you're creating and setting up a new project in Deno Deploy Web UI, or
  2. In Deno Deploy Web UI, just check "Just link the repo, I'll set up GitHub Actions myself". And then commit a GitHub Actions workflow file by yourself to your repository. CleanShot 2024-06-18 at 12 12 34

Let me explain why you encountered the very unfriendly error message "An internal server error occurred". As @willnewby pointed out, this error really was happening because the system failed to commit a new file to your repository. When a project that requires build steps (e.g. deno task build) is created, what Deno Deploy does is to create a GitHub Actions workflow file and commit it to your repo automatically on behalf of you. But this just fails if branch protections are turned on. (On side note - We should definitely forward this error message coming from GitHub to users properly to avoid confusion instead of returning "internal server error occurred". We have added this improvement to our backlog).

So going back to the possible solutions, solution 1 is to allow Deno Deploy to commit an auto-generated GitHub Actions workflow file to your repo on your behalf, and solution 2 is that you set up a GitHub Actions workflow file by yourself instead of relying on the auto-generation.

If you prefer 2, a workflow file which needs to be created under .github/workflows directory should look like this:

name: Deploy
on:
  push:
    branches: master
  pull_request:
    branches: master

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    permissions:
      id-token: write # Needed for auth with Deno Deploy
      contents: read # Needed to clone the repository

    steps:
      - name: Clone repository
        uses: actions/checkout@v4

      - name: Install Deno
        uses: denoland/setup-deno@v1
        with:
          deno-version: v1.x

      - name: Build step
        run: "deno task build"

      - name: Upload to Deno Deploy
        uses: denoland/deployctl@v1
        with:
          project: <put your Deno Deploy project name here>
          entrypoint: "main.ts"
          root: "."

After committing this file to your repo, GitHub Actions will build and deploy your fresh project to Deno Deploy on every commit to the master branch.

If there's anything that's unclear, please feel free to ask :)

rajrupdasofficial commented 5 months ago

How deno deploy will understand that this is the correct user who is trying to deploy? I am asking this question on other providers i have to use a auth token to verify that I am the right auth user who has permission to deploy but here that is not . why and how? is there some advance auth mechanism used by deno?

rajrupdasofficial commented 5 months ago

Thank you very much your solution worked just fine. Thanks a lot , now I can brag about fresh in Reddit and in front of my friends

magurotuna commented 5 months ago

How deno deploy will understand that this is the correct user who is trying to deploy? I am asking this question on other providers i have to use a auth token to verify that I am the right auth user who has permission to deploy but here that is not . why and how? is there some advance auth mechanism used by deno?

When you create a new project in Deno Deploy via https://dash.deno.com/new_project, Deno Deploy stores the GitHub repository info that you select. Then when you make some action to your GitHub repository (e.g. push to the main branch), GitHub sends a webhook message to us, which contains a signature that Deno Deploy can use to verify that it is really coming from GitHub, as well as repository info that Deno Deploy can check if this repository has been registered and associated with a Deno Deploy project.

The story is a little bit different if you use GitHub Actions based flow (in which case we rely on OIDC to confirm the validity and authenticity), but I hope this helps you get a rough understanding :)

Thank you very much your solution worked just fine. Thanks a lot , now I can brag about fresh in Reddit and in front of my friends

Glad to hear that! If there is anything that we could help more, we're happy to.

rajrupdasofficial commented 5 months ago

No there is nothing . if i face any other error i will just open a issue report