Skip to content

Conversation

david-fraley
Copy link
Collaborator

Summary

This PR adds a GitHub Action that automatically comments on pull requests with preview links when documentation files in the docs/ directory are modified.

Implementation Details

The action:

  • Triggers on PR open, synchronize (new commits), and reopen events
  • Only runs when markdown files in docs/ are changed
  • Properly URI-encodes branch names (e.g., df/claude-code-mod-v3df%2Fclaude-code-mod-v3)
  • Creates or updates a single comment with all changed documentation preview links
  • Follows the preview URL format: https://coder.com/docs/@{encoded-branch}/{doc-path}

Example

For a branch named df/claude-code-mod-v3 with changes to docs/ai-coder/tasks-core-principles.md, the action will comment:

📚 Documentation Preview Links

The following documentation pages have been modified and are available for preview:


Preview links are generated for branch: df/claude-code-mod-v3

Testing

The workflow has been tested locally for:

  • ✅ URI encoding of branch names with special characters
  • ✅ Proper URL generation matching the expected format
  • ✅ Handling multiple changed documentation files

Resolves

Addresses the request from @david-fraley to automatically comment preview links for documentation changes.

This action automatically comments on pull requests with preview links
when documentation files in the docs/ directory are modified.

Features:
- Triggers on PR open, synchronize, and reopen events
- Only runs when docs/ markdown files are changed
- URI-encodes branch names properly (e.g., slashes become %2F)
- Creates or updates a single comment with all changed doc links
- Preview URLs follow format: https://coder.com/docs/@{encoded-branch}/{doc-path}

Example: Branch 'df/claude-code-mod-v3' with changes to
'docs/ai-coder/tasks-core-principles.md' will generate:
https://coder.com/docs/@df%2Fclaude-code-mod-v3/ai-coder/tasks-core-principles
@david-fraley david-fraley changed the title feat: Add GitHub Action for automatic docs preview comments feat: add GitHub Action for automatic docs preview comments Oct 9, 2025
Use environment variables instead of direct template expansion in bash
commands to prevent potential code injection attacks through branch names.

This addresses the zizmor linter check for template injection vulnerabilities.
- Add persist-credentials: false to checkout action to prevent credential leaks
- Quote GITHUB_OUTPUT variable to fix shellcheck warnings

Addresses artipacked and shellcheck findings from CI linter.
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.

1 participant