diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e084401..7855842 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,30 @@ Rule: Do not let a customer deployment track `develop` directly. +## Dual Remote Workflow +This repository now has two different Git remotes with different purposes: +- `origin`: the normal GitHub product remote +- `tubco`: the TUBCO customer remote + +Use the helper command to avoid mixing them up: + +```bash +./scripts/git_remote_target.sh status +``` + +Common commands: + +```bash +./scripts/git_remote_target.sh push-origin +./scripts/git_remote_target.sh push-tubco release/tubco-v1 +./scripts/git_remote_target.sh set-own-identity +./scripts/git_remote_target.sh set-tubco-identity +``` + +Default rule: +- normal product work goes to `origin` +- TUBCO pushes happen only when explicitly requested + ## Current Delivery Model - GitHub Actions is used for CI - the current test server is local/LAN-only diff --git a/backend/workflows/templates/workflows/developer_handbook.html b/backend/workflows/templates/workflows/developer_handbook.html index d38f0c3..b763ee1 100644 --- a/backend/workflows/templates/workflows/developer_handbook.html +++ b/backend/workflows/templates/workflows/developer_handbook.html @@ -94,6 +94,17 @@
  • promote develop into main when stable
  • +
    +

    Dual remote rule

    + +
    ./scripts/git_remote_target.sh status
    +

    Use the helper above before pushing if there is any doubt about which remote should receive the change.

    +

    Customer release branches

    Use a dedicated release branch when a customer should receive the current stable product line but not future features by default.

    @@ -657,6 +668,8 @@ lxc.mount.entry: /dev/null sys/module/apparmor/parameters/enabled none bind 0 0<
    docker compose restart web
     docker compose restart worker

    Restart app services after code or template changes.

    +
    ./scripts/git_remote_target.sh status
    +

    Show the current branch, active local identity, and both remotes before pushing.

    Validation

    @@ -675,6 +688,15 @@ docker compose restart worker
    ./scripts/deploy_prod_from_mac.sh

    Sync the current main checkout to the production target and deploy it with production checks enabled.

    +
    +

    Remote targeting

    +
    ./scripts/git_remote_target.sh push-origin
    +./scripts/git_remote_target.sh push-tubco release/tubco-v1
    +

    Push to the intended remote explicitly instead of relying on memory.

    +
    ./scripts/git_remote_target.sh set-own-identity
    +./scripts/git_remote_target.sh set-tubco-identity
    +

    Switch between the normal commit identity and the TUBCO customer identity when needed.

    +

    Direct server deployment

    cd /opt/workdock
    diff --git a/scripts/git_remote_target.sh b/scripts/git_remote_target.sh
    new file mode 100755
    index 0000000..f77de3a
    --- /dev/null
    +++ b/scripts/git_remote_target.sh
    @@ -0,0 +1,106 @@
    +#!/usr/bin/env bash
    +set -euo pipefail
    +
    +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
    +cd "$REPO_ROOT"
    +
    +TUBCO_NAME="bostame"
    +TUBCO_EMAIL="mdbayazid@tub.co"
    +
    +usage() {
    +  cat <<'EOF'
    +Usage:
    +  ./scripts/git_remote_target.sh status
    +  ./scripts/git_remote_target.sh push-origin [ref]
    +  ./scripts/git_remote_target.sh push-tubco [ref]
    +  ./scripts/git_remote_target.sh set-own-identity
    +  ./scripts/git_remote_target.sh set-tubco-identity
    +
    +Commands:
    +  status
    +      Show current branch, current commit, active local git identity, and configured remotes.
    +
    +  push-origin [ref]
    +      Push a ref to the main product remote "origin".
    +      Default ref: current branch
    +
    +  push-tubco [ref]
    +      Push a ref to the TUBCO customer remote "tubco".
    +      Default ref: release/tubco-v1
    +
    +  set-own-identity
    +      Remove the repo-local git user.name and user.email so this repo falls back to your normal identity.
    +
    +  set-tubco-identity
    +      Set the repo-local git identity to the TUBCO customer identity.
    +EOF
    +}
    +
    +require_remote() {
    +  local remote="$1"
    +  git remote get-url "$remote" >/dev/null 2>&1 || {
    +    echo "Missing git remote: $remote" >&2
    +    exit 1
    +  }
    +}
    +
    +current_branch() {
    +  git branch --show-current
    +}
    +
    +show_identity() {
    +  local local_name local_email
    +  local_name="$(git config --local --get user.name || true)"
    +  local_email="$(git config --local --get user.email || true)"
    +  if [[ -n "$local_name" || -n "$local_email" ]]; then
    +    echo "Local repo identity: ${local_name:-} <${local_email:-unset}>"
    +  else
    +    echo "Local repo identity: not set in this repo (falls back to global/default git config)"
    +  fi
    +}
    +
    +case "${1:-}" in
    +  status)
    +    echo "Branch: $(current_branch)"
    +    echo "Commit: $(git rev-parse --short HEAD)"
    +    show_identity
    +    echo
    +    echo "Remotes:"
    +    git remote -v
    +    echo
    +    echo "Recommended targets:"
    +    echo "  develop/main/internal work -> origin"
    +    echo "  release/tubco-v1 and approved customer backports -> tubco"
    +    ;;
    +
    +  push-origin)
    +    require_remote origin
    +    ref="${2:-$(current_branch)}"
    +    echo "Pushing '$ref' to origin..."
    +    git push origin "$ref"
    +    ;;
    +
    +  push-tubco)
    +    require_remote tubco
    +    ref="${2:-release/tubco-v1}"
    +    echo "Pushing '$ref' to tubco..."
    +    git push tubco "$ref"
    +    ;;
    +
    +  set-own-identity)
    +    git config --local --unset-all user.name >/dev/null 2>&1 || true
    +    git config --local --unset-all user.email >/dev/null 2>&1 || true
    +    echo "Cleared repo-local git identity. This repo will now use your normal git identity."
    +    ;;
    +
    +  set-tubco-identity)
    +    git config --local user.name "$TUBCO_NAME"
    +    git config --local user.email "$TUBCO_EMAIL"
    +    echo "Set repo-local git identity to: $TUBCO_NAME <$TUBCO_EMAIL>"
    +    ;;
    +
    +  *)
    +    usage
    +    exit 1
    +    ;;
    +esac