GitHub Actions
Automate documentation deployment with GitHub Actions.
You can deploy your docs automatically on every push to your repository using GitHub Actions. The workflow runs npx blodemd push under the hood.
This workflow deploys your docs whenever you push to the main branch:
name: Deploy docs
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npx --yes blodemd push
env:
BLODEMD_API_KEY: ${{ secrets.BLODEMD_API_KEY }}The --yes flag tells npx to install the blodemd package without prompting.
This workflow deploys the main branch to production and creates preview deployments for pull requests:
name: Deploy docs
on:
push:
branches: [main]
pull_request:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run
The BLODEMD_BRANCH value uses github.head_ref for pull requests (the source branch name) and falls back to github.ref_name for pushes.
Blode.md also provides a composite GitHub Action that wraps the CLI. You can use it instead of running npx directly:
name: Deploy docs
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mblode/blodemd/packages/deploy-action@main
with:
api-key: ${{ secrets.BLODEMD_API_KEY }}You need a BLODEMD_API_KEY secret in your GitHub repository. Here is how to set it up:
Run blodemd push locally for the first time. When the project is created, the CLI prints an API key:
Project my-project created
API key for CI: bmd_abc123...
You can also generate an API key from the Blode.md dashboard.
BLODEMD_API_KEY and paste your API key as the valueUse ${{ secrets.BLODEMD_API_KEY }} in your workflow file as shown in the examples above.
Never commit your API key directly in your workflow file. Always use GitHub Secrets.
If your docs are not in the default location, pass the directory path as an argument or use the directory input:
- run: npx --yes blodemd push ./my-docs
env:
BLODEMD_API_KEY: ${{ secrets.BLODEMD_API_KEY }}When running in GitHub Actions, the CLI automatically detects:
GITHUB_REF_NAME: used as the branch name if BLODEMD_BRANCH is not setdocs.json auto-detection startsapi-url | string | Override the API base URL. | Yes |