Repository navigation
CI: deploy template demos when a new template is merged - #43
Merged
Merged
Conversation
Merging a PR that adds templates/<id>/package.json builds the template and publishes it to https://<id>.hostingertemplates.com through the Hostinger public API. Changes to existing templates (Dependabot security groups, manual dependency bumps) do not deploy; existing demos can be redeployed with workflow_dispatch. The API token lives in the main-only `template-demos` environment and is only exposed to the deploy job, which runs no template or npm code.
Template previewNo |
New templates deploy on merge, so the skill now covers redeploying through the workflow, diagnosing failed runs, and a short manual fallback for plan moves or when Actions is unavailable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Merging a PR that adds a template now publishes its demo to
https://<id>.hostingertemplates.comautomatically. This replaces the manual Hostinger Connector step inskills/deploy-templates. (Slack thread)When it deploys
mainthat adds atemplates/<id>/package.json(changed-templates.mjs --added).3612919(nine new templates) → all nine selected.^[a-z0-9-]+$and an existingtemplates/<id>/package.json.How
detectbuild(matrix)npm ciandnpm run build, thenpackage-demo.mjszips the resultdeploytemplate-demosenvironmentdeploy-demos.mjspublishes the zips one at a timepackage-demo.mjsdecides the deploy type:deploy.entryFile, and the build output has anindex.html(deploy.outputDirectory, elsedist,buildorout). It zips that output.git archive, leaving outpreview/,node_modulesand build output. Hostinger runsnpm ciand the build on the server.deploy-demos.mjsuses the same public API endpoints as the Hostinger MCP deploy tools (@hostinger/mcp). For each template it:hostingertemplates.com(exact domain match, never a subdomain).<id>with folder<id>if it doesn't exist, then waits until it's listed.POST …/deployGET …/nodejs/builds/settings/from-archive, merges the catalogdeploysettings (appType,buildCommand,outputDirectory,entryFile), defaults to Node 22, starts the build, then polls until it completes. If it fails, the log tail is printed.<title>. That skips Hostinger's browser-check page while DNS and TLS are still setting up.Templates are deployed one at a time on purpose: parallel subdomain creation or upload-credential requests on one account fail with unfinished-action limits and 500s.
Security
HOSTINGER_API_TOKENis stored only in thetemplate-demosenvironment, and onlymaincan deploy to it. There's no repo-level secret.pull_requestorpull_request_target, so forks and PR code never get the token.buildjob. Thedeployjob only checks out.github/scriptsand runsdeploy-demos.mjs, which uses Node built-ins only.detectselected, so a tampered build artifact can't target another subdomain.Catalog
demoUrlTEMPLATE_SCHEMA.mdnow asks fordemoUrl: https://<id>.hostingertemplates.comin the PR that adds a template. Before, it stayednulluntil someone deployed by hand.The alternative is a bot PR that writes
demoUrlafter deploying.mainneeds a review, so that would mean a second approval for every template. The cost of this choice: if a deploy fails, the catalog links to a dead demo until someone fixes it and reruns the workflow. A failed run turns red and lists the failure in the job summary.deploy-templatesskillIts description told agents to use it "when publishing, deploying, or refreshing template demos". So Dex Code or Claude asked to create and publish a template would follow the manual connector steps. That duplicates the workflow, needs an interactive Hostinger sign-in that Dex Code jobs can't do, and its catalog step contradicts the new
demoUrlrule. The skill (same file and name, 175 → 84 lines) is now a runbook:gh workflow run … --ref main -f templates="…"and watch it.Testing
callout(Vite → static),couch-to-5k(SvelteKit, catalogoutputDirectory→ static),consultancy(Nuxt SSR → Node.js),api-reference(Nest → Node.js) andquickstart(Hono,entryFile→ Node.js). Static zips haveindex.htmlat the root; source zips have nopreview/,node_modulesor build output.callout.hostingertemplates.com.actionlintis clean.After merge
callout. It redeploys an existing demo with the same content, as a first real check of the upload, subdomain and live-URL steps.template-demosenvironment created, limited tomain, withHOSTINGER_API_TOKENset.🤖 Generated with Claude Code