"#"
This commit is contained in:
36
examples/devenv.nix
Normal file
36
examples/devenv.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
# Consumer devenv.nix example
|
||||
# Add josh-sync as a flake input in your devenv.yaml or flake.nix,
|
||||
# then import the module here.
|
||||
#
|
||||
# In devenv.yaml:
|
||||
# inputs:
|
||||
# josh-sync:
|
||||
# url: github:org/josh-sync/v1.0.0
|
||||
# flake: true
|
||||
#
|
||||
# Or in flake.nix:
|
||||
# inputs.josh-sync = {
|
||||
# url = "github:org/josh-sync/v1.0.0";
|
||||
# inputs.nixpkgs.follows = "nixpkgs";
|
||||
# };
|
||||
|
||||
{ inputs, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ inputs.josh-sync.devenvModules.default ];
|
||||
|
||||
# josh-sync CLI is now available in the shell.
|
||||
# Commands:
|
||||
# josh-sync sync --forward Forward sync (mono → subrepo)
|
||||
# josh-sync sync --reverse Reverse sync (subrepo → mono)
|
||||
# josh-sync preflight Validate config and connectivity
|
||||
# josh-sync import <target> Initial import from subrepo
|
||||
# josh-sync reset <target> Reset subrepo to josh-filtered view
|
||||
# josh-sync status Show target config and sync state
|
||||
# josh-sync state show <t> [b] Show state JSON
|
||||
# josh-sync state reset <t> [b] Reset state
|
||||
|
||||
enterShell = ''
|
||||
echo "Josh Sync available — run 'josh-sync --help' for commands"
|
||||
'';
|
||||
}
|
||||
74
examples/forward.yml
Normal file
74
examples/forward.yml
Normal file
@@ -0,0 +1,74 @@
|
||||
# .gitea/workflows/josh-sync-forward.yml — Consumer workflow template
|
||||
# Syncs monorepo subfolder(s) → external subrepo(s)
|
||||
#
|
||||
# Customize:
|
||||
# - paths: list all target subfolders
|
||||
# - branches: list all monorepo branches to trigger on
|
||||
# - org/josh-sync@v1: pin to your library repo and version
|
||||
|
||||
name: "Josh Sync → Subrepo"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
# List all target subfolders here (must match .josh-sync.yml targets[].subfolder)
|
||||
- "services/billing/**"
|
||||
- "services/auth/**"
|
||||
- "libs/shared/**"
|
||||
schedule:
|
||||
- cron: "0 */6 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target:
|
||||
description: "Target to sync (empty = detect from push or all on schedule)"
|
||||
required: false
|
||||
default: ""
|
||||
branch:
|
||||
description: "Branch to sync (empty = triggered branch or all)"
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
concurrency:
|
||||
group: josh-sync-fwd-${{ github.ref_name }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: docker
|
||||
container: node:20-bookworm
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Install tools
|
||||
run: |
|
||||
apt-get update -qq && apt-get install -y -qq jq curl git openssh-client >/dev/null 2>&1
|
||||
YQ_VERSION=v4.44.6
|
||||
curl -sL "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" \
|
||||
-o /usr/local/bin/yq && chmod +x /usr/local/bin/yq
|
||||
|
||||
- name: Detect changed target
|
||||
if: github.event_name == 'push'
|
||||
id: detect
|
||||
run: |
|
||||
CHANGED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
|
||||
TARGETS=$(yq -o json '.targets' .josh-sync.yml \
|
||||
| jq -r '.[] | "\(.name):\(.subfolder)"' \
|
||||
| while IFS=: read -r name prefix; do
|
||||
echo "$CHANGED" | grep -q "^${prefix}/" && echo "$name"
|
||||
done | sort -u | tr '\n' ' ')
|
||||
echo "targets=${TARGETS}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: org/josh-sync@v1
|
||||
with:
|
||||
direction: forward
|
||||
target: ${{ github.event.inputs.target || steps.detect.outputs.targets }}
|
||||
branch: ${{ github.event.inputs.branch || github.ref_name }}
|
||||
env:
|
||||
SYNC_BOT_USER: ${{ secrets.SYNC_BOT_USER }}
|
||||
SYNC_BOT_TOKEN: ${{ secrets.SYNC_BOT_TOKEN }}
|
||||
SUBREPO_TOKEN: ${{ secrets.SUBREPO_TOKEN || secrets.SYNC_BOT_TOKEN }}
|
||||
SUBREPO_SSH_KEY: ${{ secrets.SUBREPO_SSH_KEY }}
|
||||
43
examples/josh-sync.yml
Normal file
43
examples/josh-sync.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
# .josh-sync.yml — Multi-target configuration example
|
||||
# Place this at the root of your monorepo.
|
||||
|
||||
josh:
|
||||
# Your josh-proxy instance URL (no trailing slash)
|
||||
proxy_url: "https://josh.example.com"
|
||||
# Repo path as josh sees it (org/repo on your Gitea/GitHub)
|
||||
monorepo_path: "org/monorepo"
|
||||
|
||||
targets:
|
||||
- name: "billing"
|
||||
subfolder: "services/billing"
|
||||
josh_filter: ":/services/billing"
|
||||
subrepo_url: "https://gitea.example.com/ext/billing.git"
|
||||
subrepo_auth: "https"
|
||||
branches:
|
||||
main: main
|
||||
develop: develop
|
||||
forward_only: []
|
||||
|
||||
- name: "auth"
|
||||
subfolder: "services/auth"
|
||||
josh_filter: ":/services/auth"
|
||||
subrepo_url: "git@gitea.example.com:ext/auth.git"
|
||||
subrepo_auth: "ssh"
|
||||
# Per-target credential override (reads from $AUTH_SSH_KEY instead of $SUBREPO_SSH_KEY)
|
||||
subrepo_ssh_key_var: "AUTH_SSH_KEY"
|
||||
branches:
|
||||
main: main
|
||||
forward_only: []
|
||||
|
||||
- name: "shared-lib"
|
||||
subfolder: "libs/shared"
|
||||
josh_filter: ":/libs/shared"
|
||||
subrepo_url: "https://gitea.example.com/ext/shared-lib.git"
|
||||
branches:
|
||||
main: main
|
||||
forward_only: [main] # one-way: mono → subrepo only
|
||||
|
||||
bot:
|
||||
name: "josh-sync-bot"
|
||||
email: "josh-sync-bot@example.com"
|
||||
trailer: "Josh-Sync-Origin"
|
||||
52
examples/reverse.yml
Normal file
52
examples/reverse.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
# .gitea/workflows/josh-sync-reverse.yml — Consumer workflow template
|
||||
# Checks external subrepo(s) for new commits and creates PRs on monorepo.
|
||||
# Always creates PRs, never pushes directly.
|
||||
#
|
||||
# Customize:
|
||||
# - cron schedule
|
||||
# - org/josh-sync@v1: pin to your library repo and version
|
||||
|
||||
name: "Josh Sync ← Subrepo"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 1,7,13,19 * * *" # Every 6h, offset from forward
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target:
|
||||
description: "Target to reverse-sync (empty = all)"
|
||||
required: false
|
||||
default: ""
|
||||
branch:
|
||||
description: "Branch to reverse-sync (empty = all eligible)"
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
concurrency:
|
||||
group: josh-sync-rev-${{ github.event.inputs.target || 'all' }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: docker
|
||||
container: node:20-bookworm
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install tools
|
||||
run: |
|
||||
apt-get update -qq && apt-get install -y -qq jq curl git openssh-client >/dev/null 2>&1
|
||||
curl -sL "https://github.com/mikefarah/yq/releases/download/v4.44.6/yq_linux_amd64" \
|
||||
-o /usr/local/bin/yq && chmod +x /usr/local/bin/yq
|
||||
|
||||
- uses: org/josh-sync@v1
|
||||
with:
|
||||
direction: reverse
|
||||
target: ${{ github.event.inputs.target || '' }}
|
||||
branch: ${{ github.event.inputs.branch || '' }}
|
||||
env:
|
||||
SYNC_BOT_USER: ${{ secrets.SYNC_BOT_USER }}
|
||||
SYNC_BOT_TOKEN: ${{ secrets.SYNC_BOT_TOKEN }}
|
||||
SUBREPO_TOKEN: ${{ secrets.SUBREPO_TOKEN || secrets.SYNC_BOT_TOKEN }}
|
||||
SUBREPO_SSH_KEY: ${{ secrets.SUBREPO_SSH_KEY }}
|
||||
Reference in New Issue
Block a user