docmd Deploy — GitHub Action
The docmd-io/deploy action builds your documentation site and outputs the path to the compiled assets, ready for upload to GitHub Pages or any other hosting target. It handles Node.js setup, config detection, dependency installation, and the build step in a single composable action.
Quick Start
Add the action to any workflow file in your repository:
# .github/workflows/docs.yml
name: Deploy Docs
on:
push:
branches: [main]
permissions:
contents: write
pages: write
id-token: write
jobs:
docs:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: docmd-io/deploy@v1
id: build
- uses: actions/upload-pages-artifact@v3
with:
path: ${{ steps.build.outputs.site-dir }}
- uses: actions/deploy-pages@v4
id: deploy
Reusable Workflow (Recommended)
If you want the absolute minimum boilerplate, use the hosted reusable workflow. It handles permissions, checkout, build, upload, and deploy in one call:
# .github/workflows/docs.yml
on:
push:
branches: [main]
jobs:
docs:
uses: docmd-io/deploy/.github/workflows/deploy.yml@v1
This is the recommended approach for new projects and the docmd Template.
Inputs
| Input | Default | Description |
|---|---|---|
node |
20 |
Node.js version to use during the build |
Outputs
| Output | Description |
|---|---|
site-dir |
Relative path to the compiled site directory (e.g. site/) |
What the Action Does
The action runs the following steps internally:
- Sets up Node.js using the specified version.
- Detects your config — searches the repository tree (up to two levels deep) for
docmd.config.json,docmd.config.js, ordocmd.config.ts. Subdirectory configs are fully supported. - Initialises docmd — if no config is found, runs
npx @docmd/core initto scaffold one automatically. - Installs dependencies — runs
npm ciif apackage.jsonis present, otherwise installs@docmd/coredirectly. - Builds the site — runs
npx @docmd/core buildand reads the output directory from your config. - Outputs the path — exposes
site-dirso the upload step knows where to find the compiled assets.
First-Time Setup
GitHub Pages must be configured to deploy from GitHub Actions (not from a branch). This is a one-time step per repository:
- Go to your repository on GitHub.
- Navigate to Settings → Pages.
- Under Source, select GitHub Actions.
- Save.
After this, every push to main triggers a deployment automatically.
Nested Config Support
If your docmd.config.json lives in a subdirectory — for example, packages/docs/docmd.config.json in a monorepo — the action detects it and passes --cwd to docmd automatically. No manual path configuration is required.
Custom Domain
To use a custom domain:
- Add a
CNAMEfile to yourdocs/directory (or your configured assets folder) containing your domain, e.g.docs.example.com. - Set the
urlfield indocmd.config.jsonto your custom domain so sitemaps and canonical tags are correct. - Configure the domain in Settings → Pages → Custom domain.
Pinning the Action Version
For production documentation sites, pin to a specific release tag rather than @v1:
- uses: docmd-io/deploy@v1.0.0
id: build
This prevents unexpected behaviour from future minor updates.
Troubleshooting
Error: Dependencies lock file is not found
This occurs when actions/setup-node is configured with cache: 'npm' but no package-lock.json exists. The docmd-io/deploy action handles caching internally — do not add a separate actions/setup-node step with cache: 'npm' when using this action.
Build succeeds but the site is not live
Ensure GitHub Pages is set to deploy from GitHub Actions, not from a branch. See First-Time Setup above.
Config not detected
The action searches up to two directory levels. If your config is deeper, pass --cwd manually in a custom workflow step or use the Deployer Package to generate a tailored workflow.