Deployment

How to deploy a site built with Lume.

Deploy manually with rsync

This is the simplest way to deploy a site: just build the site and upload it to your server with rsync. An easy way is by creating a script in your _config.ts file to automate this process:

site.script(
  "deploy",
  "lume --location=https://my-site.com",
  "rsync -r _site/ user@my-site.com:~/www",
);

This is a simple script that execute two commands: It builds the site with the final location URL and upload the site to the server. Now, to build and deploy your site, just run:

lume run deploy

GitHub Pages

To deploy a Lume site using GitHub Pages, create the following workflow:

name: Publish on GitHub Pages

on:
  push:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest

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

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

      - name: Build site
        run: |
          deno run -A https://deno.land/x/lume/ci.ts

      - name: Deploy
        uses: crazy-max/ghaction-github-pages@v2.0.1
        with:
          build_dir: _site
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GitLab Pages

To deploy a Lume site using GitLab Pages, set a CI/CD configuration with the following code:

image: oscarotero/lume

stages:
  - pages

pages:
  stage: pages
  script: lume --dest=public

  artifacts:
    paths:
      - public

The --dest=public argument in the build command set the destination folder as ./public. This is the folder that GitLab use to publish the site. This argument is not needed if you have defined the dest folder in the config file.

Deno Deploy

Deno Deploy is a distributed deploy system provided by Deno with support for static files. It requires to have your repo in GitHub.

  • Sign up in Deno Deploy and create a new project.
  • Configure the Git integration to use the GitHub Actions deployment mode.
  • In your repository, you need a entrypoint file to server the files. Create the file serve.ts with the following code:
import Server from "https:/deno.land/x/lume/core/server.ts";

const server = new Server({
  port: 8000,
  root: `${Deno.cwd()}/_site`,
});

server.start();

console.log("Listening on http://localhost:8000");
  • Create the following GitHub workflow, replacing project-name with the name of your project in Deno Deploy.
name: Publish on Deno Deploy

on:
  push:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read

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

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

      - name: Build site
        run: |
          deno run -A https://deno.land/x/lume/ci.ts

      - name: Deploy to Deno Deploy
        uses: denoland/deployctl@v1
        with:
          project: project-name
          entrypoint: server.ts

Netlify

Netlify doesn't include Deno installed by default but it's possible to install and use it in the build command.

Create netlify.toml file in your repository with the following code:

[build]
  publish = "_site"
  command = """
    curl -fsSL https://deno.land/x/install/install.sh | sh && \
    /opt/buildhome/.deno/bin/deno run -A https://deno.land/x/lume/ci.ts \
  """

Vercel

Vercel, doesn't have Deno available by default so the build command must install it.

curl -fsSL https://deno.land/x/install/install.sh | sh && /vercel/.deno/bin/deno run -A https://deno.land/x/lume/ci.ts

Remember also to configure the output directory to _site.

Fleek

To deploy your Lume site with Fleek, create a .fleek.json file in your repository with the following code:

{
  "build": {
    "image": "oscarotero/lume",
    "command": "lume",
    "publicDir": "_site"
  }
}

Cloudflare Pages

To deploy your Lume site with Cloudflare Pages, configure the build command as follow:

curl -fsSL https://deno.land/x/install/install.sh | sh && /opt/buildhome/.deno/bin/deno run -A https://deno.land/x/lume/ci.ts

Remember to configure the output directory to _site.

AWS Amplify

To deploy your Lume site with AWS Amplify create a amplify.yml file with the following code:

version: 1
frontend:
  phases:
    build:
      commands:
        - curl -fsSL https://deno.land/x/install/install.sh | sh
        - /root/.deno/bin/deno run -A https://deno.land/x/lume/ci.ts
  artifacts:
    baseDirectory: /_site
    files:
      - '**/*'
  cache:
    paths: []

Remember to ignore amplify.yml file in the Lume _config.ts file. If you don't want to create this file in your repository, you can configure it in the AWS control panel.