"#"
This commit is contained in:
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 }}
|
||||
Reference in New Issue
Block a user