Skip to content
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

API for deploying by URL #29

Open
lewisl9029 opened this issue May 8, 2021 · 4 comments
Open

API for deploying by URL #29

lewisl9029 opened this issue May 8, 2021 · 4 comments

Comments

@lewisl9029
Copy link

lewisl9029 commented May 8, 2021

Hi deno team!

I really, really love the fact that you've built the ability to deploy through a script hosted on the web!

As much as I love git, I don't think it's necessarily the right primitive for deploying web applications, since git clones take a non-trivial amount of time and serves as a minimum latency floor for our iteration cycles. Static assets, on the other hand, feels like a much better primitive since it is the de-facto primitive of the web, and has minimal latency overhead for propagating updates.

That said, one thing I would love to see is the ability to hook into deno deploy's ability to create deployments using a script, through some kind of unofficial API. I see that right now, this is done through the following API call:

await fetch("https://dash.deno.com/api/projects/_redacted_/deployments_stream", {
    "headers": {
        "authorization": "Bearer _redacted_",
        "content-type": "application/json",
    },
    "body": "{\"url\":\"https://_redacted_\",\"production\":true}",
    "method": "POST",
});

I can already call this API outside of the Deno deploy dashboard, but the fact that there's no way to get issued a persistent authorization token makes the usage rather awkward, as I'd have to deal with the fact that my dashboard token can expire, and manually refresh it from time to time.

Would you please consider the ability to issue an API token from the dashboard to allow other tools to leverage Deno deploy more conveniently? No need to offer any guarantee of API stability, given the early experimental state of the service itself. This could totally stay a use-at-your-own-risk type of thing for the foreseeable future.

Thanks!

@ewired
Copy link

ewired commented May 8, 2021

Suggestion which would work for one use-case I have:

As a user of a collaborative ES module editing app, I want Deno Deploy to provide a "Webhook URL" (a la Discord) which triggers a refresh/re-deployment of the provided module URL, so that the latest rough draft of the service is re-deployed when my colleague or I click a button in the editor.

My example does not include the ability to provide a new URL; only to refresh the one provided on the dashboard. I imagine the webhook URL should include a randomized string to prevent unauthorized interruptions, while being more flexible to work with than authorization tokens, just as in Discord's webhook URLs for sending a message.

@wperron
Copy link

wperron commented May 10, 2021

Persistent API tokens are being worked on, it's something we've known about for a while, it just hasn't been released yet. The API endpoint you found is indeed the correct one, though you can also use POST /api/projects/:project_id/deployments instead which doesn't stream the response body -- the streaming part is meant to stream back the output of the dependency downloads step which happen on Deploy's side, it's really meant to be exposed on the front-end (though if you want to stream that back to stdout, knock yourself out!)

That being said, it should be noted that the GitHub integration is not cloning the entire repository. The webhook is used to send a request to Deploy that there is a new commit on the default branch. From there, the process is very similar to deploying from a URL, we simply take the raw.githubusercontent.com version of the entrypoint at the new commit and use that as the source URL. It's really just a way to automate the update the source URL.

If you're interested in scripting your updates, you can also check out the unstable Terraform provider which includes a client SDK (written in Go) for the API.

@lucacasonato
Copy link
Member

We have static tokens now (create them via your account page). The API is not documented and subject to change, but for now you can use POST https://dash.deno.com/api/projects/:project_id/deployments to create new deployments. As William said this is not a streaming endpoint - it completes with the response only once the deployment has been completed.

@tchief
Copy link

tchief commented Jul 26, 2022

Does POST https://dash.deno.com/api/projects/:project_id/deployments endpoint still works?

It replies with 404, and GET works fine.
POST to deployment_with_assets also works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants