Skip to content

[Breaking] Artifact-based rewrite#18

Merged
pavi2410 merged 8 commits intomainfrom
artifact-based-rewrite
Mar 6, 2026
Merged

[Breaking] Artifact-based rewrite#18
pavi2410 merged 8 commits intomainfrom
artifact-based-rewrite

Conversation

@pavi2410
Copy link
Owner

@pavi2410 pavi2410 commented Mar 6, 2026

Summary

This PR is the full v4 -> v5 rewrite of html-preview-action.

The branch started by modernizing the action implementation and test setup, then moved the action to a new artifact-first architecture, and finally simplified the public API around the v5 direction: previewing HTML generated during CI as GitHub Actions artifacts.

Compared to v4, v5 is a breaking release with a narrower, clearer scope.

v4 -> v5 highlights

What v4 was designed for

v4 was built around previewing checked-in repository files by constructing an htmlpreview.github.io URL that points at a GitHub blob URL.

That only works for content that htmlpreview.github.io can read publicly from GitHub, which made it a reasonable fit for checked-in repo files but not for CI-generated preview payloads or private artifact-like output.

What v5 is designed for

v5 is intentionally focused on the most common and best-supported use case this project wants to support going forward:

  • HTML generated during CI
  • preview payloads uploaded as GitHub Actions artifacts
  • linked local HTML/assets discovered automatically under site_root

The new implementation:

  • resolves html_file within site_root
  • recursively discovers linked local HTML pages and assets
  • ignores remote, unsafe, missing, and out-of-root references
  • uploads a single-file payload as raw when possible
  • falls back to archive upload for multi-file previews

Runtime and tooling modernization

  • upgraded the action runtime from Node 20 to Node 24
  • migrated the implementation from legacy JavaScript entrypoints to TypeScript source under src/
  • switched the packaged action bundle to dist/index.mjs
  • added tsconfig.json and tsdown bundling
  • moved the repo to pnpm
  • replaced the old generated bundle/layout with the new ESM build output

Public API changes

The final v5 API is simpler and more explicit:

  • removed mode
  • removed artifact_format
  • added upload with supported values:
    • auto
    • archive
  • renamed input artifact_name to archive_name
  • kept the action artifact-only

Output changes

Kept common outputs:

  • url
  • artifact_url
  • artifact_id
  • artifact_name
  • discovered_files_count
  • skipped_references_count
  • comment_body

Added:

  • result_json

Removed older / more confusing outputs:

  • mode
  • upload_strategy
  • artifact_count
  • artifact_names
  • artifact_ids
  • artifact_urls
  • artifact_manifest
  • source_url

Documentation updates

The README was rewritten for v5 to explain:

  • the artifact-only model
  • how discovery works behind the scenes
  • how upload behavior is resolved
  • when this action is a good fit
  • when this action is not a good fit
  • how to compose PR comments yourself
  • how to migrate from v4 repo-mode usage

The migration section now includes:

  • a direct pointer from the top-level breaking-change note
  • a copy-pasteable workflow step that recreates the old repo/blob preview URL pattern for users who still need that behavior

Test and workflow changes

This PR also substantially upgrades verification coverage:

  • added TypeScript unit tests around discovery, path safety, upload strategy, metadata, and helper behavior
  • added richer test fixtures for:
    • single-file previews
    • linked multi-file previews
    • path escape attempts
  • reworked .github/workflows/test.yml to run quality checks first
  • updated action-invocation workflow coverage for the new artifact-only API
  • added a dedicated v4_compatibility workflow job that validates the documented repo/blob fallback URL construction

Repository cleanup

  • removed old IDE project files from the repo
  • removed obsolete root-level sample/test files that no longer fit the new structure
  • updated .gitignore
  • removed the old package-lock.json
  • added pnpm-lock.yaml

Why this change

The old design was centered on checked-in repo files that could be fetched publicly through htmlpreview.github.io.

v5 makes the action more explicit and maintainable by focusing on CI-generated HTML preview artifacts, while still giving former v4 users a documented fallback path when they still want the old checked-in-file behavior.

Verification

Verified with:

  • pnpm format:check
  • pnpm test
  • pnpm typecheck
  • pnpm lint
  • pnpm build

Migration notes

For users upgrading from v4:

  • v5 no longer supports repo/blob mode inside the action itself
  • if you still need the old checked-in-file behavior, either stay on v4 or use the documented workflow fallback that constructs:
https://htmlpreview.github.io/?https://github.com/<owner>/<repo>/blob/<sha>/<html_file>

@pavi2410 pavi2410 self-assigned this Mar 6, 2026
@pavi2410 pavi2410 added the enhancement New feature or request label Mar 6, 2026
pavi2410 added 3 commits March 7, 2026 00:15
…ng validation logic

Remove assertions for deprecated `mode`, `upload_strategy`, `artifact_count`, and `artifact_manifest` outputs. Replace with `result_json` validation using grep. Update input names from `artifact_format`/`artifact_name` to `upload`/`archive_name`. Replace `preview_repo_mode` job with `v4_compatibility` job that demonstrates fallback pattern for users migrating from repo-mode usage.
@pavi2410 pavi2410 changed the title Artifact-based rewrite [Breaking] Artifact-based rewrite Mar 6, 2026
@pavi2410 pavi2410 linked an issue Mar 6, 2026 that may be closed by this pull request
@pavi2410 pavi2410 merged commit b58683c into main Mar 6, 2026
5 checks passed
@pavi2410 pavi2410 deleted the artifact-based-rewrite branch March 6, 2026 19:52
@pavi2410 pavi2410 linked an issue Mar 6, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make this action more useful than just generating a URL 404 Not Found

1 participant