Skip to content

Conversation

@hoegertn
Copy link
Contributor

@hoegertn hoegertn commented Jan 29, 2026

Description

This PR adds comprehensive support for deploying documentation to GitHub Pages through both a standalone workflow and as a reusable pipeline step.

Changes

New Components:

  • GithubPagesWorkflow: A new component that creates a complete GitHub Actions workflow for building and deploying documentation to GitHub Pages
  • GithubPagesDeployStep: A reusable pipeline step that can be integrated into CDK pipelines or other workflows

Features:

  • Configurable build commands and documentation folder paths
  • Support for custom domains with automatic CNAME file generation
  • Flexible Node.js version selection
  • Optional dependency installation with custom install command support
  • Custom runner tags for self-hosted runners
  • Proper GitHub Actions permissions (contents:read, pages:write, id-token:write)
  • Multi-platform support (GitHub, GitLab, Bash)
  • Integration with existing CDK Pipeline infrastructure

Configuration Options:

  • buildCommand: Required - command to generate documentation
  • docsFolder: Output directory (default: 'docs')
  • customDomain: Optional custom domain for GitHub Pages
  • workflowName: Workflow file name (default: 'github-pages')
  • branchName: Trigger branch (default: 'main')
  • runnerTags: Runner configuration (default: ['ubuntu-latest'])
  • nodeVersion: Node.js version (default: '20')
  • runInstall: Enable/disable dependency installation (default: true)
  • installCommand: Custom install command
  • artifactName: GitHub Pages artifact name (default: 'github-pages')

Testing

Comprehensive test coverage includes:

  • Default configuration behavior
  • Custom options (domain, folder, branch, runner tags, Node version)
  • Integration with CDK pipelines as post-deployment steps
  • Multi-platform step configuration (GitHub, GitLab, Bash)
  • Snapshot tests for generated workflow files

Example Usage

// Standalone workflow
new GithubPagesWorkflow(project, {
  buildCommand: 'npm run build:docs',
  docsFolder: 'dist/docs',
  customDomain: 'docs.example.com',
});

// As CDK pipeline post-deploy step
const ghPagesDeploy = new GithubPagesDeployStep(app, {
  buildCommand: 'npm run build:api-docs',
  docsFolder: 'api-docs',
  customDomain: 'api.example.com',
});

new GithubCDKPipeline(app, {
  stages: [{
    name: 'prod',
    postDeploySteps: [ghPagesDeploy],
  }],
});

Adds GithubPagesDeployStep for building and deploying documentation to GitHub Pages using GitHub Actions deployment mode.

Features:
- Configurable build command for generating docs
- Configurable docs folder path
- Custom domain support via CNAME file
- Uses official GitHub Actions (upload-pages-artifact@v3 and deploy-pages@v4)
- Includes proper permissions (pages: write, id-token: write)
- Support for GitHub, GitLab, and Bash deployment targets
- Comprehensive test coverage with snapshots

The step can be used standalone or integrated into CDK pipelines as a post-deployment step.
Adds GithubPagesWorkflow class that creates a complete GitHub Actions workflow for deploying documentation to GitHub Pages.

Features:
- Creates a workflow that checks out code, sets up Node.js, and installs dependencies
- Integrates with GithubPagesDeployStep for building and deploying docs
- Configurable build command, docs folder, and custom domain
- Configurable workflow name, branch triggers, and runner tags
- Optional dependency installation with custom install commands
- Uses official GitHub Actions for Pages deployment
- Includes proper permissions and concurrency controls
- Comprehensive test coverage with 15 test cases and snapshots

Usage example:
```typescript
new GithubPagesWorkflow(project, {
  buildCommand: 'npm run build:docs',
  docsFolder: 'dist/docs',
  customDomain: 'docs.example.com',
});
```

This simplifies GitHub Pages setup by handling all the boilerplate workflow configuration.
@github-actions github-actions bot requested a review from Lock128 January 29, 2026 10:48
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@hoegertn hoegertn changed the title Add GitHub Pages deployment workflow and step support feat: GitHub Pages deployment workflow and step support Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants