This commit is contained in:
2026-02-12 11:22:51 +03:00
parent 7c2d731399
commit f2785241bf
6 changed files with 16 additions and 16 deletions

View File

@@ -22,4 +22,4 @@ Initial release. Extracted from [private-monorepo-example](https://code.itkan.io
- Python + pyyaml replaced by yq-go (single static binary) - Python + pyyaml replaced by yq-go (single static binary)
- 7 separate scripts replaced by single `josh-sync` CLI - 7 separate scripts replaced by single `josh-sync` CLI
- Consumer workflows use composite action (`uses: org/josh-sync@v1`) - Consumer workflows use composite action (`uses: https://your-gitea/org/josh-sync@v1`)

View File

@@ -35,7 +35,7 @@ Copy from [examples/](examples/) and customize paths/branches:
```yaml ```yaml
# .gitea/workflows/josh-sync-forward.yml # .gitea/workflows/josh-sync-forward.yml
- uses: org/josh-sync@v1 - uses: https://your-gitea.example.com/org/josh-sync@v1
with: with:
direction: forward direction: forward
env: env:
@@ -59,7 +59,7 @@ Run `josh-sync preflight` to validate your setup.
## CLI ## CLI
``` ```
josh-sync sync [--forward|--reverse] [--target NAME] [--branch BRANCH] josh-sync sync [--forward|--reverse] [--target NAME[,NAME]] [--branch BRANCH]
josh-sync preflight josh-sync preflight
josh-sync import <target> josh-sync import <target>
josh-sync reset <target> josh-sync reset <target>

View File

@@ -56,9 +56,9 @@ runs:
env: env:
JOSH_SYNC_DEBUG: ${{ inputs.debug == 'true' && '1' || '0' }} JOSH_SYNC_DEBUG: ${{ inputs.debug == 'true' && '1' || '0' }}
run: | run: |
ARGS="--config ${{ inputs.config }}" ARGS=(--config "${{ inputs.config }}")
[[ "${{ inputs.direction }}" == "forward" ]] && ARGS+=" --forward" [[ "${{ inputs.direction }}" == "forward" ]] && ARGS+=(--forward)
[[ "${{ inputs.direction }}" == "reverse" ]] && ARGS+=" --reverse" [[ "${{ inputs.direction }}" == "reverse" ]] && ARGS+=(--reverse)
[[ -n "${{ inputs.target }}" ]] && ARGS+=" --target ${{ inputs.target }}" [[ -n "${{ inputs.target }}" ]] && ARGS+=(--target "${{ inputs.target }}")
[[ -n "${{ inputs.branch }}" ]] && ARGS+=" --branch ${{ inputs.branch }}" [[ -n "${{ inputs.branch }}" ]] && ARGS+=(--branch "${{ inputs.branch }}")
josh-sync sync $ARGS josh-sync sync "${ARGS[@]}"

View File

@@ -81,7 +81,7 @@ Global flags:
Sync flags: Sync flags:
--forward Forward only (mono → subrepo) --forward Forward only (mono → subrepo)
--reverse Reverse only (subrepo → mono) --reverse Reverse only (subrepo → mono)
--target NAME Filter to one target (env: JOSH_SYNC_TARGET) --target NAME Filter to target(s) — comma-separated for multiple (env: JOSH_SYNC_TARGET)
--branch BRANCH Filter to one branch --branch BRANCH Filter to one branch
Environment: Environment:
@@ -137,7 +137,7 @@ _sync_direction() {
target_name=$(echo "$TARGET_JSON" | jq -r '.name') target_name=$(echo "$TARGET_JSON" | jq -r '.name')
# Filter to specific target if requested # Filter to specific target if requested
if [ -n "$filter_target" ] && [ "$filter_target" != "$target_name" ]; then if [ -n "$filter_target" ] && ! echo ",$filter_target," | grep -q ",${target_name},"; then
continue continue
fi fi

View File

@@ -4,7 +4,7 @@
# Customize: # Customize:
# - paths: list all target subfolders # - paths: list all target subfolders
# - branches: list all monorepo branches to trigger on # - branches: list all monorepo branches to trigger on
# - org/josh-sync@v1: pin to your library repo and version # - uses: https://your-gitea.example.com/org/josh-sync@v1 pin to your library repo and version
name: "Josh Sync → Subrepo" name: "Josh Sync → Subrepo"
@@ -59,10 +59,10 @@ jobs:
| jq -r '.[] | "\(.name):\(.subfolder)"' \ | jq -r '.[] | "\(.name):\(.subfolder)"' \
| while IFS=: read -r name prefix; do | while IFS=: read -r name prefix; do
echo "$CHANGED" | grep -q "^${prefix}/" && echo "$name" echo "$CHANGED" | grep -q "^${prefix}/" && echo "$name"
done | sort -u | tr '\n' ' ') done | sort -u | paste -sd ',' -)
echo "targets=${TARGETS}" >> "$GITHUB_OUTPUT" echo "targets=${TARGETS}" >> "$GITHUB_OUTPUT"
- uses: org/josh-sync@v1 - uses: https://your-gitea.example.com/org/josh-sync@v1
with: with:
direction: forward direction: forward
target: ${{ github.event.inputs.target || steps.detect.outputs.targets }} target: ${{ github.event.inputs.target || steps.detect.outputs.targets }}

View File

@@ -4,7 +4,7 @@
# #
# Customize: # Customize:
# - cron schedule # - cron schedule
# - org/josh-sync@v1: pin to your library repo and version # - uses: https://your-gitea.example.com/org/josh-sync@v1 pin to your library repo and version
name: "Josh Sync ← Subrepo" name: "Josh Sync ← Subrepo"
@@ -40,7 +40,7 @@ jobs:
curl -sL "https://github.com/mikefarah/yq/releases/download/v4.44.6/yq_linux_amd64" \ 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 -o /usr/local/bin/yq && chmod +x /usr/local/bin/yq
- uses: org/josh-sync@v1 - uses: https://your-gitea.example.com/org/josh-sync@v1
with: with:
direction: reverse direction: reverse
target: ${{ github.event.inputs.target || '' }} target: ${{ github.event.inputs.target || '' }}