Skip to content

feat: Add GitHub Pages deployment workflow for /site folder#6

Merged
JoshuaAFerguson merged 1 commit into
masterfrom
claude/github-pages-subfolder-setup-01DEdMcT8xgGNpH5rQFPJHrD
Nov 14, 2025
Merged

feat: Add GitHub Pages deployment workflow for /site folder#6
JoshuaAFerguson merged 1 commit into
masterfrom
claude/github-pages-subfolder-setup-01DEdMcT8xgGNpH5rQFPJHrD

Conversation

@JoshuaAFerguson

Copy link
Copy Markdown
Member

Summary

Implements GitHub Actions workflow to automatically deploy the /site folder to GitHub Pages using the gh-pages branch approach.

Changes:

  • Added .github/workflows/github-pages.yml workflow
  • Automatically deploys /site contents to gh-pages branch on push to main
  • Supports manual workflow dispatch for on-demand deployments

Why this approach:

  • GitHub Pages only supports root, /docs, or branches - not arbitrary subfolders like /site
  • Using GitHub Actions allows us to keep our current structure (/docs for technical docs, /site for website)
  • Standard industry practice for deploying from subfolders

Configuration Required After Merge

  1. Go to repository Settings → Pages
  2. Set Source to "Deploy from a branch"
  3. Select branch: gh-pages and folder: / (root)
  4. Save

Test Plan

  • Created workflow file with proper permissions
  • Committed and pushed to feature branch
  • Merge to main
  • Verify workflow runs successfully
  • Configure GitHub Pages settings
  • Verify site is accessible at https://joshuaaferguson.github.io/streamspace/

Related

Resolves the issue where GitHub Pages cannot serve from the /site subfolder directly.

Implements GitHub Actions workflow to automatically deploy /site folder
to gh-pages branch. This allows GitHub Pages to serve the website from
a subfolder without requiring repository restructuring.

- Triggers on pushes to main branch that modify /site or the workflow
- Uses peaceiris/actions-gh-pages action for deployment
- Publishes /site contents to root of gh-pages branch
- Supports manual workflow dispatch
@JoshuaAFerguson JoshuaAFerguson merged commit 141e794 into master Nov 14, 2025
@JoshuaAFerguson JoshuaAFerguson deleted the claude/github-pages-subfolder-setup-01DEdMcT8xgGNpH5rQFPJHrD branch November 14, 2025 18:10
JoshuaAFerguson pushed a commit that referenced this pull request Nov 15, 2025
Implements Task #6 from IMPLEMENTATION_ROADMAP.md - complete template version
control with snapshot/restore functionality similar to git.

Changes to api/internal/db/database.go:

Database Schema (user_session_template_versions table):
- Add user_session_template_versions table for version control
- Serial ID primary key with auto-incrementing version numbers
- template_id references user_session_templates
- version_number (INT, unique per template)
- template_data (JSONB, full snapshot of template configuration)
- description (TEXT, version notes/changelog)
- created_by (user who created version)
- tags (TEXT[], optional version tags like "stable", "v1.0")
- UNIQUE constraint on (template_id, version_number)
- 3 indexes for query optimization (template_id, created_by, created_at)

Changes to api/internal/handlers/sessiontemplates.go:

Template Versioning (Task #6):
- Replace placeholder ListTemplateVersions with real pagination
- Implement CreateTemplateVersion with template snapshot
- Implement RestoreTemplateVersion with auto-backup safety
- Add permission helpers: canAccessTemplate, canModifyTemplate
- Add internal createVersionSnapshot for auto-backups
- Add PostgreSQL array helpers for tags

ListTemplateVersions Implementation:
- Permission check via canAccessTemplate (owner or shared)
- Pagination support (query params: page, limit)
- Defaults: page=1, limit=50, max=100
- Returns versions ordered by version_number DESC (newest first)
- Includes total count for pagination UI
- Parses PostgreSQL TEXT[] arrays for tags
- Comprehensive JSON unmarshaling for template_data JSONB

CreateTemplateVersion Implementation:
- Permission check via canModifyTemplate (owner or write/manage)
- Snapshots current template using row_to_json()
- Auto-increments version using MAX(version_number) + 1
- Stores full template configuration as JSONB
- Supports optional description and tags
- Converts tags to PostgreSQL array format
- Returns new version ID and version number
- Logs version creation for audit trail

RestoreTemplateVersion Implementation:
- Permission check via canModifyTemplate
- Retrieves specified version from database
- **Safety mechanism**: Creates auto-backup before restoring
- Updates all template fields with versioned data
- Gracefully continues if backup fails (logs warning)
- Comprehensive audit logging for restore operations
- Updates timestamp on template modification

Permission Helpers:
- canAccessTemplate: Checks ownership or any share access (read)
- canModifyTemplate: Checks ownership or write/manage permission
- Both integrate with template_shares for permission inheritance

Internal Helpers:
- createVersionSnapshot: Creates version snapshot (used for backups)
- splitPostgresArray: Parses PostgreSQL TEXT[] to Go []string
- joinPostgresArray: Converts Go []string to PostgreSQL array format
- splitByComma: Handles comma-separated values with quote handling

Technical Details:
- Added strings import for string manipulation
- TemplateVersion struct for response serialization
- row_to_json() for efficient template snapshotting
- COALESCE(MAX(version_number), 0) + 1 for auto-increment
- PostgreSQL array format: {"tag1","tag2","tag3"}
- Auto-backup tagged with "auto-backup" for identification

Security Features:
- User ownership verification for all operations
- Permission-based access control (read vs. write/manage)
- Template share integration
- SQL injection protection with parameterized queries
- Auto-backup before restore protects against data loss

IMPLEMENTATION_ROADMAP.md Updates:
- Mark Task #6 (Template Versioning) as COMPLETED
- Update progress: 67% (6/9 tasks)
- P2 Medium Priority now 100% complete (3/3)
- Document all three operations with implementation details
- Include database schema, permission system, helper functions

Impact:
- Template versioning now production-ready with git-like version control
- Users can create snapshots of templates at any time
- Users can restore templates to previous versions safely
- Auto-backup prevents accidental data loss during restore
- Full audit trail with version history
- Complete ALL P2 Medium Priority tasks (3/3 completed)
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.

2 participants