2026-02-12 09:20:55 +03:00
|
|
|
# .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
|
2026-02-12 11:22:51 +03:00
|
|
|
# - uses: https://your-gitea.example.com/org/josh-sync@v1 — pin to your library repo and version
|
2026-02-12 09:20:55 +03:00
|
|
|
|
|
|
|
|
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"
|
2026-02-12 11:22:51 +03:00
|
|
|
done | sort -u | paste -sd ',' -)
|
2026-02-12 09:20:55 +03:00
|
|
|
echo "targets=${TARGETS}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
2026-02-14 21:28:40 +03:00
|
|
|
- uses: https://your-gitea.example.com/org/josh-sync@v1.2
|
2026-02-12 09:20:55 +03:00
|
|
|
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 }}
|