Deno logoDeno

deployctl

deployctl is a command line tool for deploying your code to Deno Deploy, and it's also a GitHub Action for the same purpose.

The default GitHub integration of Deno Deploy automatically uploads the files in your repository as Static Assets and you can access those files in Deno Deploy. However this static assets support is limited to the files in your repository with the default GitHub integration.

If you like to dynamically generate the static assets during the build steps, you need to use deployctl.

deployctl CLI

You can install deployctl command with the below command:

deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -r -f https://deno.land/x/deploy/deployctl.ts

You also need to set your Personal Access Token to DENO_DEPLOY_TOKEN environment variable. You can generate your Personal Access Token in https://dash.deno.com/user/access-tokens .

Usages

To deploy a local script:

deployctl deploy --project=helloworld main.ts

To deploy a remote script:

deployctl deploy --project=helloworld https://deno.com/examples/hello.js

To deploy a remote script without static files:

deployctl deploy --project=helloworld --no-static https://deno.com/examples/hello.js

To ignore the node_modules directory while deploying:

deployctl deploy --project=helloworld --exclude=node_modules main.tsx

See the help message (deployctl -h) for more details.

deployctl GitHub Action

There's also deployctl GitHub Action which wraps and automates the above command line usages.

You just need to include the deployctl GitHub Action as a step in your workflow.

You do not need to set up any secrets for this to work. You do need to link your GitHub repository to your Deno Deploy project and choose the "GitHub Actions" deployment mode. You can do this in your project settings on https://dash.deno.com.

job:
  permissions:
    id-token: write # This is required to allow the GitHub Action to authenticate with Deno Deploy.
    contents: read
  steps:
    - name: Deploy to Deno Deploy
      uses: denoland/deployctl@v1
      with:
        project: my-project # the name of the project on Deno Deploy
        entrypoint: main.ts # the entrypoint to deploy

By default the entire contents of the repository will be deployed. This can be changed by specifying the root option.

- name: Deploy to Deno Deploy
  uses: denoland/deployctl@v1
  with:
    project: my-project
    entrypoint: index.js
    root: dist

The entrypoint can either be a relative path or file name, or a an absolute URL. If it is a relative path, it will be resolved relative to the root. Both absolute file:/// and https:// URLs are supported.

To deploy the ./dist directory using the std/http/file_server.ts module, you can use the following configuration:

- name: Deploy to Deno Deploy
  uses: denoland/deployctl@v1
  with:
    project: my-project
    entrypoint: https://deno.land/std/http/file_server.ts
    root: dist

See deployctl README for more details.