Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 23, 2025

This PR implements comprehensive preview and publication URL handling for Digital Adaptation Kit (DAK) repositories as requested in the issue.

Key Changes

Enhanced DAK JSON Generation

  • Added previewUrl and canonicalUrl fields to the DAK JSON structure
  • Implemented WHO-specific publication URL pattern: https://smart.who.int/{stub} where {stub} is the repository name with any smart- prefix removed
  • Added branch-aware canonical URL selection: publication URLs for release branches (release-*), preview URLs for development branches

New DAK URL Utilities

  • Created input/scripts/dak_url_utils.py with shared URL generation logic
  • Supports both WHO and non-WHO repositories with appropriate fallback patterns
  • Provides DAK configuration loading and branch-aware URL resolution

GitHub Workflow Integration

  • Enhanced .github/workflows/ghbuild.yml to regenerate DAK configuration with current branch context
  • Added environment variable setup for proper URL generation during CI builds
  • Maintains backward compatibility for repositories without dak.json

PR Comment Script Updates

  • Updated pr_comment_start.py and pr_comment_finish.py to use DAK-aware URL generation
  • Graceful fallback to GitHub Pages patterns for non-DAK repositories
  • Integration with new DAK utilities while maintaining existing functionality

Logical Model & Documentation

  • Updated input/fsh/models/DAK.fsh to include previewUrl and canonicalUrl fields
  • Enhanced documentation in input/pagecontent/index.md with comprehensive DAK URL handling explanation
  • Clear documentation of branch-based URL selection logic

URL Patterns

WHO Repositories:

  • Publication: https://smart.who.int/base (for smart-base repo)
  • Preview: https://worldhealthorganization.github.io/smart-base

Non-WHO Repositories:

  • Publication: Uses canonical from sushi-config.yaml or GitHub Pages fallback
  • Preview: Standard GitHub Pages pattern

Branch Logic:

  • Release branches (release-*): Use publication URL for canonical references
  • Development branches: Use preview URL for canonical references

The implementation is backward-compatible and maintains all existing functionality while adding the requested DAK-specific URL capabilities.

Fixes #173.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Copilot AI changed the title [WIP] and preview and publicaiton url to DAK LM and json Add preview and publication URL support to DAK LM and JSON generation Sep 23, 2025
Copilot AI requested a review from litlfred September 23, 2025 01:50
@litlfred
Copy link
Collaborator

Utilize the new workflow called publication release.
WorldHealthOrganization/smart-html#34

If branchbnqme.is attern release-* then once it finishes ghbuiild successlly.deploted, it should kick off a pulll request to smart-html for that release of that repo if a PR has an already been created and is open. PR should be generated by adding content of smart,-YYY/gh-pages/branches/release-XXX to dir -YYY of smart-html repo.

@litlfred
Copy link
Collaborator

litlfred commented Oct 9, 2025

merge upstream @copilot

@litlfred litlfred marked this pull request as ready for review October 9, 2025 17:52
Copilot AI review requested due to automatic review settings October 9, 2025 17:52
@litlfred litlfred merged commit 764280b into main Oct 9, 2025
1 check failed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive preview and publication URL handling for Digital Adaptation Kit (DAK) repositories, adding URL configuration fields and branch-aware URL selection logic to support both WHO and non-WHO repositories.

  • Enhanced DAK JSON generation with previewUrl and canonicalUrl fields alongside branch-aware URL selection
  • Created shared DAK URL utilities for consistent URL generation across build scripts
  • Updated PR comment scripts to use DAK-aware URL generation with graceful fallbacks

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
input/scripts/pr_comment_start.py Updated to use DAK-aware URL generation with fallback to GitHub Pages patterns
input/scripts/pr_comment_finish.py Updated to use DAK-aware URL generation with fallback to GitHub Pages patterns
input/scripts/generate_dak_from_sushi.py Enhanced with URL generation logic supporting WHO/non-WHO repos and branch-based selection
input/scripts/dak_url_utils.py New utility module providing shared DAK URL generation and configuration loading
input/pagecontent/index.md Added comprehensive documentation of DAK URL handling patterns and branch logic
input/fsh/models/DAK.fsh Updated logical model to include previewUrl and canonicalUrl fields
dak.json Updated with new URL fields and corrected publication URL protocol
.github/workflows/ghbuild.yml Enhanced workflow to regenerate DAK config with current branch context

def generate_publication_url(repo_name: str, canonical_url: str) -> str:
"""Generate publication URL based on repository ownership and name."""
# Check if this is a WorldHealthOrganization repository
if os.getenv('GITHUB_REPOSITORY', '').startswith('WorldHealthOrganization/'):
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded organization name 'WorldHealthOrganization/' should be extracted to a constant or configuration to improve maintainability and make it easier to adapt for other organizations.

Copilot uses AI. Check for mistakes.
profile, repo = github_repo.split('/')
base_url = f"https://{profile}.github.io/{repo}"
else:
base_url = "https://worldhealthorganization.github.io/smart-base"
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded fallback URL should be extracted to a constant or made configurable to avoid magic strings in the code.

Copilot uses AI. Check for mistakes.
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.

and preview and publicaiton url to DAK LM and json

2 participants