What is Deno Deploy?
Deno Deploy is a hosting service for Deno by Deno Land Inc..
It requires only GitHub account. For free plan, no additional registers, credit-cards and payments are required.
Deploy methods
0. Playground
You can try it on a browser.
After login to Deno Deploy, then on Deploy dashboard, click 'New Playgroung'.
Now code editor is here.
Write code here and save, then deployed soon. It live at the deno.dev
URL what you can see upper right of the code editor.
It supports not only TS and JS, also TSX and JSX are.
Note
Project named with random words. On this screen-shot, it wasfresh-crown-29
.
1. deployctl
CLI
This method deploys local files via deployctl
CLI.
At first, install deployctl
.
deno install -gArf jsr:@deno/deployctl
deployctl -h
# Other way to execute
~/.deno/bin/deployctl -h
Next, make any working directory.
mkdir work
cd work
Then write any HTTP server.
// main.ts
Deno.serve((req: Request) => new Response("Hello World"));
At last, deploy it by deployctl
. Nothing to do for dashboard.
ls
# main.ts
deployctl deploy --project=akuad-helloworld --entrypoint=main.ts
Note
If specified project name is already in use, it be an errorerror: APIError: This project name is already in use.
Set other project name.
At first time of deploy or few days elapsed deploy (session expired?), authentication page open on a browser. Authorize it.
All done! On dashboard, you can see a created project.
Let's access the URL.
curl https://akuad-helloworld.deno.dev/
# Hello World
To re-deploy with same project name, instance will be added to the project.
# After source editing, type same command
deployctl deploy --project=akuad-helloworld --entrypoint=main.ts
Note
prod
badge means Production instance. The instance can be access with<project-name>.deno.dev
.To set production, click 'Promote to Production' in '︙' menu.
Or set production on CLI, add
--prod
option when deploy.deployctl deploy --project=akuad-helloworld --> entrypoint=main.ts --prod
2. GitHub repository + dashboard control
This method deploys GitHub repository files on browser control.
Click 'New Project' on dashboard.
Select a GitHub account and a repository.
Note
At first time, no repositories will be shown. Because Deno Deploy has no access permissions for all repositories. Click 'Modify GitHub Permissions' to grant permission.
After selected a repository, project configuration will be shown.
Fill them, then click 'Deploy Project'. All done!
On pushed or merged to specified 'Production Branch', re-deploy automatically.
3. GitHub Actions
This method deploys GitHub repository files via GitHub Actions (CD).
Click 'New Project' on dashboard.
Select a GitHub account, a repository and a production branch. Check 'Just link the repo...', then click 'Create Project'. On this case, project configuration will not be shown.
For next, let's setup GitHub Actions workflow on selected repository.
Sample workflow is on official docs.
name: Deploy
on:
push:
branches: main
pull_request:
branches: main
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@v2
with:
deno-version: v2.x
- name: Build step
run: "deno task build"
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "<your-project-name>"
entrypoint: "main.ts"
root: "."
Note
entrypoint:
is related path fromroot:
directory.
Finally, when specified on:
event triggered, it will be deployed.
All done! You don't have to manage any access tokens or environment variables.
Conclusion
You can start free deployment for Deno with Deno Deploy. Every ways are easy to start.
Top comments (0)