# Deploy helper now resolves Forgejo/GitHub remotes without hardcoded `origin`

Date: 2026-05-17 · Issue: islandflow-1ei · Files changed: scripts/deploy.ts

## Summary

Updated `scripts/deploy.ts` so deploy operations no longer assume a git remote named `origin`. The deploy helper now auto-resolves an available remote (Forgejo-aware), uses it consistently across fetch/pull/push and remote checkout updates, and supports explicit override with `DEPLOY_GIT_REMOTE`.

## Changes Made

- Added `DEPLOY_GIT_REMOTE` environment override to force a specific remote when needed.
- Added local helper functions to discover remotes, inspect branch upstream metadata, and resolve deploy remote candidates.
- Changed local prechecks from hardcoded `git fetch origin` / `origin/main` to resolved remote values.
- Changed branch publish from hardcoded pushes to remote-aware push commands.
- Changed remote VPS git update steps from hardcoded `origin` fetch/pull/track to remote-aware commands.
- Updated deploy CLI help/environment text and rollout log output to show selected git remote.

## Context

The repository now includes `forgejo` and `github` remotes and may not define `origin` at all. Hardcoding `origin` caused deploy fragility in both local precheck and remote rollout flows.

## Important Implementation Details

Remote resolution prioritizes explicit operator intent and branch metadata, then falls back to a stable preference order and discovered remotes.

    candidates = [
      DEPLOY_GIT_REMOTE,
      branch.<name>.remote,
      upstream remote,
      branch.main.remote,
      forgejo, origin, github,
      all discovered remotes
    ]

The selected remote is then threaded through all deploy git operations to avoid local/remote mismatch from hardcoded remote names.

## Expected Impact for End-Users

Operators should no longer see deploy failures caused solely by missing `origin`. Deploy commands should work in mixed Forgejo/GitHub environments with fewer manual fixes and less confusion.

## Validation

- Ran `bun run scripts/deploy.ts --help` to verify updated usage and environment output.
- Ran `bun test` (232 passing, 0 failing) after code changes.
- Searched the updated file to verify key `origin` hardcodes were removed from deploy flow paths.

## Issues, Limitations, and Mitigations

- If local and VPS remote naming differ unexpectedly, deploy can still fail during remote git update.
- Mitigation: `DEPLOY_GIT_REMOTE` allows explicit remote selection per run.
- The current change does not rewrite deployment README examples; they may still mention `origin` in historical/manual sections.

## Follow-up Work

- Optional: update deployment docs to describe dynamic remote resolution and `DEPLOY_GIT_REMOTE` usage examples.
- No additional code follow-up required for the reported deploy.ts Forgejo mismatch.