+234 814 007 4714 [email protected]
Hosting

Deploying from GitHub

Your site can publish itself whenever you push to GitHub. Your repository's own GitHub Actions workflow builds the site, then NG Domain's deploy Action (justiceo/ngdomain-deploy-action) publishes the finished files. NG Domain never sees your code, only the built site, and you see every build's log in GitHub.

You need a GitHub repository with your site in it, and permission to change its settings.

Set it up

Open Sites, click your site and, in the Publishing card, click Set up next to GitHub Actions. You can also pick Deploy from GitHub on the thank-you page after buying a site. The dashboard takes you through five steps.

1. Framework

Pick what builds your site: Hugo, Eleventy or Next.js static export. Each builds into its own folder, which the workflow publishes. For another generator, start from the Next.js workflow and change its build command and folder.

The first step of Deploy from GitHub, asking what builds the site, with Hugo, Eleventy and Next.js static exportThe first step of Deploy from GitHub, asking what builds the site, with Hugo, Eleventy and Next.js static export

A Next.js site must export static files. See Hosting a Next.js Static Export.

2. Workflow

Copy the workflow file and save it in your repository as .github/workflows/ngdomain.yml. For a Hugo site it looks like this:

name: Deploy to NG Domain
on:
  push:
    branches: [main]
concurrency: ngdomain-deploy
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: peaceiris/actions-hugo@v3
        with:
          hugo-version: latest
          extended: true
      - run: hugo --minify
      - uses: justiceo/ngdomain-deploy-action@v1
        with:
          directory: public
          token: ${{ secrets.NGDOMAIN_DEPLOY_TOKEN }}

It runs on every push to main. If your default branch has another name, change it in the file.

The workflow step, showing the workflow file for a Hugo site and a Copy workflow buttonThe workflow step, showing the workflow file for a Hugo site and a Copy workflow button

3. Token

Click Create token. The deploy token lets the workflow publish this site and nothing else. Copy it now: it's shown only once.

The token step with a new deploy token shown once and a Copy token buttonThe token step with a new deploy token shown once and a Copy token button

4. Secret

Add the token to your repository as a secret, so it never appears in your code:

  1. In your repository on GitHub, open Settings › Secrets and variables › Actions.
  2. Choose New repository secret.
  3. Name it NGDOMAIN_DEPLOY_TOKEN.
  4. Paste the token and choose Add secret.

Back in the dashboard, click I've added it.

5. First version

Commit the workflow file and push:

git add .github/workflows/ngdomain.yml && git commit -m "Deploy to NG Domain" && git push

The dashboard waits for the workflow to finish, then shows the first version. From then on, every push to main publishes a new version.

The last step, saying adaskitchen.com.ng publishes from GitHub Actions, with its first version from commit a41c9e2 on mainThe last step, saying adaskitchen.com.ng publishes from GitHub Actions, with its first version from commit a41c9e2 on main

When a build fails

GitHub shows why in your repository's Actions tab, and your live site isn't touched. Fix the problem and push again. Each version on the site's Versions tab shows the commit it came from, so you can roll back to an earlier one. See Publishing by Upload.

Deploy tokens

The Publishing card on your site's page lists its deploy tokens. A site holds up to five.

The Publishing card with GitHub Actions publishing on every push to main, Upload, and a github-actions deploy tokenThe Publishing card with GitHub Actions publishing on every push to main, Upload, and a github-actions deploy token
  • Another repository or CI: click Create next to Deploy tokens and name the token after where it's used. One token per place means you can revoke one without stopping the others.
  • A leaked token: click Revoke next to it. Anything that publishes with it stops at once. Create a new one and update the NGDOMAIN_DEPLOY_TOKEN secret.
  • The workflow file again: click Workflow in the Publishing card.

Uploading still works while GitHub publishes the site. The next push replaces an uploaded version.